-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[8.x] Ensure attribute is Collection when casting even if value is null #36730
Conversation
Maintains `null` value in database if the value is still empty and the original value was `null` When casting attribute to `asCollection` you can now start using it without checking if it is set or not.
Allow setting the attribute to an empty array or even resetting back to null
Please add some tests. |
Not sure how your code will interact with a nullable json column.
|
Co-authored-by: Tom Irons <tom.irons@hotmail.com>
Co-authored-by: Tom Irons <tom.irons@hotmail.com>
It will still work with nullable columns. You will still be able to set the attribute to |
Seems like a breaking change. I don't really plan to change this behavior. Free to make your own cast if you need something different. |
Currently when casting an attribute to
asCollection
it only casts it if the value isn'tnull
, creating an issue when you want to start pushing or using the collection.This PR ensures you always get a
Collection
but still maintains thenull
value in the database if the attribute is still empty and the original value wasnull
upon saving.Benefit: You can just use the attribute as a collection without checking if it is indeed a
Collection