Skip to content

uuid_binary_ordered_time not working with IN expression #164

@ger86

Description

@ger86

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions