-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use enum values from enumType in DiscriminatorColumn and check DiscriminatorMap values against it #12065
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
base: 3.6.x
Are you sure you want to change the base?
Use enum values from enumType in DiscriminatorColumn and check DiscriminatorMap values against it #12065
Conversation
|
What's the correct way to turn off tests for DBAL versions not supporting enumType? |
|
You could mark the test as skipped unless |
|
Let's try this now. |
9ad4a23 to
fa84570
Compare
|
MySQL also required. :) |
fa84570 to
15bb988
Compare
|
Sorry, that was depressing. Last attempt for now. |
|
Retargeting to 3.6.x since this is a new feature. |
| } | ||
|
|
||
| if (! $this->getTestEntityManager()->getConnection()->getDatabasePlatform() instanceof AbstractMySQLPlatform) { | ||
| self::markTestSkipped('Test valid for MySQL/MariaDB only.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shouldn't we run this test on other DBMS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests were failing on SQLite. I'm not sure which other feature detection we should use to skip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were they failing though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I look at it it the more confused I get. :) Now I'm thinking Types::ENUM doesn't need to be involved at all when setting the values in ClassMetadata, because you should still get the values from the enum class even if not using type enum in the database. But it's 2AM, will test tomorrow.
f4617f5 to
689a5eb
Compare
|
|
|
Things got a bit clearer. It seems I was mislead by the title "Implement an EnumType for MySQL/MariaDB", where in fact it works for all databases, but just maps the value to string. So Types::ENUM should always be used to populate values. |
76dcaee to
b84e46a
Compare
|
Can you please squash your commits together and give the remaining commit a good message? |
Check DiscriminatorMap keys match enum cases. Test values are populated from enum cases and mismatched values throw an exception. Fixes doctrine#11794
b84e46a to
6da5cc4
Compare
Thanks, done now. Hopefully correctly. :) |
| ); | ||
| } | ||
|
|
||
| $values = $this->discriminatorColumn->options['values'] ?? null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm now thinking we should wrap these checks in if ($this->discriminatorColumn?->enumType !== null), otherwise DiscriminatorColumn without enumType, but with options: ['values' => ['...']] will fail. Though values probably shouldn't be used without.
Fix for issue #11794.
Currently the values of enumType in DiscriminatorColumn are ignored which results in an error when generating a migration:
Fixed by populating values from the enum and also prevent invalid entries in DiscriminatorMap.