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 8000
UniqueEntityValidator fails when the unique value is a custom doctrine type field #21619
Closed
@magarzon

Description

@magarzon
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0