-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Enh. #20171 - possible breaking changes: Support JSON columns for MariaDB 10.4 or higher. #20184
Comments
The change also impact the yii\behaviors\AttributeTypecastBehavior on line 269 with the following error Array to string conversion |
The
It is certainly Related: #18390 |
I don't thing we should revert the change - it is definitely a step in the right direction, however, it does break existing code. Maybe all it needs is a warning in big letters that this may break code... |
Thanks for the suggestion, i'll add the note. |
I will do some more tests and will give you an update about the AttributeTypecastBehavior |
The problem is caused by the default validation rules in the model. Depending on the configuration of the AttributeTypecastBehavior, the value will be detected automatically based on validation rules. So everyone needs to make changes on their models, before updating to v2.0.50. |
If prior to Yii2 2.0.50 a MariaDB JSON field was used in a model, the contents needed manual json_encode before save (otherwise MySQL errored because of invalid JSON data).
Issue 1: Since this change, a manual json_encode on the field before assigning this to an AR attribute is basically double-encoding the data - data_type -> JSON string -> JSON.
Issue 2: If the JSON attribute used to have a 'string' validator in the model (which was the closest to no validator at all), now the validation fails if the original data type is not a string.
I realize these are not directly Yii issues, but they are Yii changes that break existing code behavior.
Short of testing if the attribute already is a valid JSON string before the encoding in the query builder, I'm not sure what the solution may be...
The text was updated successfully, but these errors were encountered: