-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix array casts as string #3418
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
Fix array casts as string #3418
Conversation
Hi @paulinevos, could you please review my PR?
@hans-thomas in general, the changes look good. I am a little bit worried about the BC impact of this change, as any fields that previously used an array cast will have been saved as JSON string and won't be read successfully in future. To mitigate this, we need to do two things:
- Create a new
json
cast that people should use instead ofarray
(ignore if something like that already exists in Laravel) - Emit a deprecation notice in
isJsonCastable
if someone is using anarray
cast. If they are, we should tell them to either use thejson
cast if they want to store the array as a JSON-encoded string, or to remove the array cast if they want to store it as an array. We can then remove that deprecation notice in the next major version.
With the _id
vs. id
issue fresh in my mind, I don't want to create another data migration problem for users, so we need to give people the option to retain the old behaviour, no matter how useless it may be in MongoDB.
Hello everyone :)
As described here #3306, when casting an array attribute as
array
, it will save as a JSON-encoded string.In this PR, I prevent casting an array to a string.