8000 [DoctrineBridge] ORMQueryBuilderLoader not compatible with binary UUID columns · Issue #39207 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DoctrineBridge] ORMQueryBuilderLoader not compatible with binary UUID columns #39207

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

Closed
colinodell opened this issue Nov 27, 2020 · 0 comments · Fixed by #39210
Closed

[DoctrineBridge] ORMQueryBuilderLoader not compatible with binary UUID columns #39207

colinodell opened this issue Nov 27, 2020 · 0 comments · Fixed by #39210

Comments

@colinodell
Copy link
Contributor
colinodell commented Nov 27, 2020

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)

@colinodell colinodell added the Bug label Nov 27, 2020
nicolas-grekas added a commit that referenced this issue Nov 28, 2020
…derusse)

This PR was merged into the 5.2 branch.

Discussion
----------

[DoctrineBridge] Fix form EntityType with filter on UID

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #39207
| License       | MIT
| Doc PR        | -

Convert UUID and ULID to the right format in ORMQueryBuilder

/cc @nicolas-grekas

Commits
-------

9e83bb7 Fix form EntotyType with uid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0