You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that #19272 modified the way that ActiveRecord array attributes are compared when marking them as dirty.
The newest version sorts the old and new array values recursively before comparing for equality.
This makes perfect sense for associative arrays, however the change didn't take lists into account.
I assume that we should first check if the array is not associative by using BaseArrayHelper::isIndexed or similar, and sort only if it's associative (not indexed). Otherwise the above mentioned PR is a breaking change and should be noted
What steps will reproduce the problem?
Changing the order of array elements for an ActiveRecord property doesn't mark the attribute as dirty.
Is the array stored as a JSON in the DB? IIRC the order of the elements there is arbitrary and you cannot rely on it anyway.
We're using a MySQL back-end for ActiveRecord. From my understanding, the order of items in an JSON array is preserved, but key => value pairs can be arbitrarily sorted and should not be relied on (hence the linked PR is perfect for that)
I think there's a still a bug with this, isValueDifferent() is sorting the arrays if they aren't associative when it's supposed to be sorting them when they ARE associative.
I've noticed that #19272 modified the way that ActiveRecord
array
attributes are compared when marking them as dirty.The newest version sorts the old and new array values recursively before comparing for equality.
This makes perfect sense for associative arrays, however the change didn't take lists into account.
I assume that we should first check if the array is not associative by using
BaseArrayHelper::isIndexed
or similar, and sort only if it's associative (not indexed). Otherwise the above mentioned PR is a breaking change and should be notedWhat steps will reproduce the problem?
Changing the order of array elements for an ActiveRecord property doesn't mark the attribute as dirty.
What is the expected result?
The
data
attribute should should be[2, 1]
What do you get instead?
The
data
attribute is[1, 2]
(Didn't get committed to DB)Additional info
The text was updated successfully, but these errors were encountered: