mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
QueryBuilder does not work with UUID in MySQL 8 #7029
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @krstns on GitHub (Aug 30, 2022).
BuMySQLort
As per: https://stackoverflow.com/questions/73530182/how-to-properly-use-uuid-with-doctrine-when-using-mysql-database
QueryBuilder does not mysql 8 uuid implementation.
Summary
After deploying a project on MySQL 8 database instead of Postgres 13 as usual we found some functionality broken - when filtering was used the data was not retrieved from the database even though full lists and single items were retrieved ok.
After closer analysis we have found that retrieving entities using UUID passed as string does not work when a QueryBuilder was used instead of a simple
findorfindBycall.Current behavior
Using string with entity UUID in query builder does not work when the id is of type UUID in the MySQL 8 database, while it works fine with Postgres 13/14.
How to reproduce
Given:
calling:
will fail, but:
will work.
Expected behavior
Should work in MySQL 8 in the same way as it does in Postgres 13/14.
@derrabus commented on GitHub (Aug 30, 2022):
Which
Uuidclass is this?@krstns commented on GitHub (Aug 30, 2022):
sorry, forgot to add it, it's the Symfony Uuid:
Symfony\Component\Uid\Uuid@derrabus commented on GitHub (Aug 30, 2022):
Please open a bug at https://github.com/symfony/symfony then.
@krstns commented on GitHub (Aug 30, 2022):
@derrabus will do. Since I don't know the inner workings of the QueryBuilder, I thought that if passing reference to an entity works for Postgres it would also work for MySQL.
@mhitza commented on GitHub (Oct 31, 2023):
@krstns have you created an upstream ticket for this issue (couldn't easily find one)?
Encountering something similar when using a
findBy(['id' => ['uuid..', 'uuid...']), when following the official symfony documentation and this boilerplate codenote: for reference I'm working around this issue by reencoding the UUID strings ids to binary by mapping
Uuid::fromString($id)->toBinary()@derrabus what is the recommended approach, if the symfony UUID component is no supported by Doctrine, when one wants to use UUID's for entity primary keys?