-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Symfony version(s) affected: 5.2.0-RC2
Description
After upgrading from 5.2.0-RC1 to 5.2.0-RC2, choice fields for entities using UUIDs as identifiers will fail validation with an error of "This choice does not exist or is not unique".
I believe this regression is a combination of #39113 changing the column type to BINARY
and the query builder trying to use the string representation when querying for them (see #39135 (comment) for a similar issue).
Tracing through the code, DoctrineChoiceLoader
calls ORMQueryBuilderLoader::getEntitiesByIds()
which returns the matching entity on 5.2.0-RC1 but returns an empty result set on 5.2.0-RC2.
I have replicated this issue on MySQL 5.7 and MariaDB 10.3.
How to reproduce
Create an entity with a UUID ID like this:
class Foo
{
/**
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidV4Generator::class)
*/
private Uuid $id;
// ...
}
Create a form that exposes the list of these entities:
// NOTE: I'm using EasyAdminBundle for this, but I suspect you'd get the same result with a vanilla Symfony form
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('foo')->setRequired(true),
// ...
];
}
Then attempt to select the entity from the list, submit the form, and get an error that the choice doesn't exist.
Possible Solutions
Modify the ORMQueryBuilderLoader
code to inform Doctrine of the proper field type or convert it to binary beforehand? (untested; based on #39135 (comment)) Or rollback #39113 (probably undesired)