Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to query by an array of Uuid #11712

Open
fmonts opened this issue Nov 11, 2024 · 1 comment
Open

Unable to query by an array of Uuid #11712

fmonts opened this issue Nov 11, 2024 · 1 comment

Comments

@fmonts
Copy link

fmonts commented Nov 11, 2024

It seems we are currently unable to query by an array of Uuids.

Neither

$leads = $this->em->getRepository(Lead::class)->findBy(['uuid' => $uuids]);

nor

$leads = $this->em->getRepository(Lead::class)->createQueryBuilder('l')
    ->where('l.uuid IN (:uuids)')
    ->setParameter('uuids', $uuids)
    ->getQuery()
    ->getResult();

work.
Tested with Mysql 8.0.36. They are sent to db as strings, with the dashes included:

image

Tried with both strings and Uuid objects.

The findOneBy method works:

image

@fmonts
Copy link
Author

fmonts commented Nov 11, 2024

Found a working solution, but it looks like a workaround:

$ids = array_map(fn($uuid) => Uuid::fromString($uuid)->toBinary(), $ids);

$leads = $this->em->getRepository(Lead::class)->createQueryBuilder('l')
    ->where('l.uuid IN (:ids)')
    ->setParameter('ids', $ids, ArrayParameterType::BINARY)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant