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'm not sure if it's a Model#isDirty bug or Model#serialize() related.
Please have a look at the situation:
There is a model instance (a user) which we've backed up with $.Model#backup call. Model.User.attributes static property had the following set of attributes at that moment: { createdDate:"date", id:"string", modifiedDate: "date", name: "string" }
This attributes definitions reflected on the _backupStore snapshot made with backup call.
An Ajax call happened to retrieve other instances of users (Model.User.findAll()). This call returned a list of users which had more properties and they were added to the Class.attributes during conversion. { createdDate:"date", id:"string", modifiedDate: "date", name: "string", termsAcceptedOn: "date" // new attribute }
The original user object was not touched on this step.
Now we call isDirty() on the original object and it appears to be dirty because now it was serialized with new set of attributes.
So what could be wrong:
Model#serialize() uses Class.attributes to serialize an object. Even if the object doesn't have an attribute, the attribute will be serialized as undefined in case it's defined in Class.attributes.
Model#isDirty() uses its own same implementation which returns false in case the number of attributes on two objects is different. Absolutely the same objects, which were serialized on different points of time and have different number of undefined attributes.
The text was updated successfully, but these errors were encountered:
I'm not sure if it's a Model#isDirty bug or Model#serialize() related.
Please have a look at the situation:
$.Model#backup
call.Model.User.attributes
static property had the following set of attributes at that moment:{ createdDate:"date", id:"string", modifiedDate: "date", name: "string" }
This attributes definitions reflected on the
_backupStore
snapshot made with backup call.Class.attributes
during conversion.{ createdDate:"date", id:"string", modifiedDate: "date", name: "string", termsAcceptedOn: "date" // new attribute }
The original user object was not touched on this step.
So what could be wrong:
Model#serialize()
usesClass.attributes
to serialize an object. Even if the object doesn't have an attribute, the attribute will be serialized asundefined
in case it's defined inClass.attributes
.Model#isDirty()
uses its ownsame
implementation which returns false in case the number of attributes on two objects is different. Absolutely the same objects, which were serialized on different points of time and have different number of undefined attributes.The text was updated successfully, but these errors were encountered: