Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DoctrineBridge] Fix invalid guess with enumType #45012

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

Merged
merged 1 commit into from
Jan 14, 2022

Conversation

jderusse
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Since doctrine/orm#9304 doctrine allows Enums with the new enumType option.
ie.

#[ORM\Column(type: 'string', enumType: Status::class, length: 1)]
public Status $status;

The issue is, it break validations at several places:

  • doctrinerExtractor guess it's a string (Because of type = string), and validation adds the constraint Assert\Type(string)
  • doctrineLoader guess it's a string with a maxLength and validation adds a constrain Assert\Length(max=1)

@jderusse jderusse requested a review from dunglas as a code owner January 13, 2022 14:34
@carsonbot carsonbot added this to the 4.4 milestone Jan 13, 2022
@carsonbot carsonbot changed the title Fix invalid guess with enumType [DoctrineBridge] Fix invalid guess with enumType Jan 13, 2022
@jonag
Copy link

jonag commented Jan 13, 2022

I was playing with the last version of Doctrine this afternoon and ran into this exact issue. This also prevent the Serializer to correctly denormalize an object which one of its property is an enum.

I was looking for a way to fix this but you were faster. Anyway, I tried your patch and it works like a charm, thank you 👌 !

@nicolas-grekas
Copy link
Member

Thank you @jderusse.

@nicolas-grekas nicolas-grekas merged commit 3974dc1 into symfony:4.4 Jan 14, 2022
@derrabus
Copy link
Member

Thank you! 🙂

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

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.