-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Array to string conversion when invalid value in enum array column #11796
Comments
@greg0ire orm/src/Mapping/ReflectionEnumProperty.php Lines 54 to 86 in 5a59923
Scratch that, I was wrong. The reproducer wasn't complete, it was missing |
Bug Report
Summary
When querying an entity having an array of enum containing a value that does not exists in the PHP enum, I got the following error:
Current behavior
Using a json column with enumType, if the database contains a value that is not in the enum, so an exception is thrown by
AbstractHydrator::buildEnum
then converted to another exception in SimpleObjectHydrator. During this conversion, the original value is casted into string. In case of array of enum (json or simple array),$originalValue
contains an array of string that can not be casted to string. So we got the "Array to string conversion" error instead of a proper error about a case not listed in the enum.This case is pretty common, for exemple when a case have been removed from the PHP enum, or when a value that have been added on a branch, when switching to another branch, the value is still in the database but does not exist anymore on the PHP enum.
Expected behavior
A proper exception explaining a case in the database is not listed in the enum like for single enum case columns.
How to reproduce
I also created a test that reproduce this error : #11795
The text was updated successfully, but these errors were encountered: