-
-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Description
Hi,
I have an entity with its identifier sets as uuid_binary_ordered_time. When I try to use a IN expression with queryBuilder, I cannot get it work.
I try with different ways but none of them works well: I get no results.
First attempt:
$queryBuilder
->andWhere('t.id IN (:ids)')
->setParameter(
'ids',
array_map(fn (string $id) => Uuid::fromString($id)->getBytes(), $testIds)
);
Second attempt:
// Second
$queryBuilder
->andWhere('t.id IN (:ids)')
->setParameter(
'ids',
implode(',', array_map(fn ($id) => UuidV1::fromString($id), $excludeIds)),
UuidBinaryOrderedTimeType::NAME
);
I can make it work with the ugly following code, but for performance reasons (and for avoiding tricky code 😂 ) I prefer to make it work using IN clause:
$clauseTemplate = 't.id = :testId%d';
$clauses = [];
foreach ($testIds as $key => $testId) {
$clauses[] = sprintf($clauseTemplate, $key);
$queryBuilder->setParameter(
sprintf('testId%d', $key),
$testId,
UuidBinaryOrderedTimeType::NAME
);
}
$queryBuilder->andWhere(implode(' OR ', $clauses));
Is this a known bug?
Before posting this issue I have searched the issued and found a possible answer here #18 (comment) but it doesn't work.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels