-
Notifications
You must be signed in to change notification settings - Fork 31
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
When wait: true, serialization not applied to attributes passed to the save method. #52
Comments
I can verify this. If the structure of the model is fundamentally changed in a custom The only way I can imagine this working in the current form is to create a dummy model with the new attributes, serialize that (using the same Example time. If this is my serialize method:
It turns returns an object that looks like this:
If I do
|
I believe this would be solved by #58 Re-open this if it didn't. |
@pgilad I cannot reopen, but this issue was not resolved. The problem is that this line:
assigns In the I will make a PR if I get to resolving this in my project, but it's currently a lower priority. |
Actually started working on this, and the complexity to support all of these simultaneously quickly becomes staggering:
You can do 2 at a time fairly easily, but to do all 3 requires keeping track of the changed attributes (already done by state), and also being aware of way the model is serialized in order to cherry-pick those attributes out of the data. Not impossible, but possibly ill-advised. Which brings me to my next point: don't devise APIs that require data attributes to be in a nested object. |
Circling back on this so the record is here. I ended up extending AmpersandModel to support JSON-API and just got around to releasing it. I changed https://github.com/bobholt/ampersand-jsonapi-model I think the strategy there should work within AmpersandModel. I should hopefully have some time next week to make a PR here that accomplishes the same thing. |
Thanks for keeping with this @bobholt, sorry it didn't get reopened. Doing that now. |
Thanks @Wrathgar. |
Submitted fix for this as #64. |
If I have a model with a property
someDate
of typedate
, I get two different serialization results when I save with{wait: true}
, depending on if I set someDate prior to invoking save, or if I pass it to the save function as follows:Line 67 appears to be the culprit.
Perhaps I am wrong, but something akin to the requested enhancement in ampersand-state Issue #122 seems to be needed so solve this.
The text was updated successfully, but these errors were encountered: