8000 UniqueEntityValidator fails when the unique value is a custom doctrine type field · Issue #21619 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

UniqueEntityValidator fails when the unique value is a custom doctrine type field #21619

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
magarzon opened this issue Feb 15, 2017 · 3 comments

Comments

@magarzon
Copy link
magarzon commented Feb 15, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.1.10

When the unique field selected is a field with a Doctrine Custom Type, and there is a violation in the validation (i.e., the value already exists in the database), the method validate in UniqueEntityValidator throws a Doctrine/Common/Persistence/Mapping/MappingException: The class 'Whatever' was not found in the chain configured namespaces AppBundle\Entity

This is due to the modifications introduced in this commit: b3ced86

And is due to this method that is called to build the violation error in the validate method:

private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, $value)

If the field value is an object (as in the case of a Doctrine custom type), it assumes that it's a Doctrine entity and try to get its identifiers, and there is when the exception is thrown, because the object is not an entity and it's not mapped

@dmaicher
Copy link
Contributor

Thanks for the bug report. I could reproduce the issue and this case was indeed not considered 😢

I proposed a fix in #21656.

fabpot added a commit that referenced this issue Feb 21, 2017
…umns (dmaicher)

This PR was merged into the 3.2 branch.

Discussion
----------

[DoctrineBridge] Fixed validating custom doctrine type columns

| Q             | A
| ------------- | ---
| Branch?       | 3.1
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21619
| License       | MIT
| Doc PR        | -

This fixes #21619 by not assuming the invalid `$value` is a Doctrine entity if its an object

Commits
-------

ad59370 [DoctrineBridge] Fixed validating custom doctrine type columns
@fabpot fabpot closed this as completed Feb 21, 2017
@iBasit
Copy link
iBasit commented Jun 8, 2017

How do we use this?

@xabbuh
Copy link
Member
xabbuh commented Jun 8, 2017

@iBasit What do you mean?

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

No branches or pull requests

7 participants
0