-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
JSONSerializer.serializeHasMany() behaves differently depending on the way the record has been added to the store #3760
Comments
Thanks for reporting! The bug is here: https://github.com/emberjs/data/blob/master/packages/ember-data/lib/serializers/json-serializer.js#L1127
When you do The |
First of all thank you for your quick and detailed answer. I've noticed the difference between the two serializers, but I didn't know whether it was on purpose or not. With your explanation it's now clear. Thanks |
I would still consider this a bug. Unknown relationships should be omitted when serializing records using |
`serializeHasMany()` omits unknown relationships rather than setting them to `undefined`.
`serializeHasMany()` omits unknown relationships of pushed record rather than setting them to `undefined`.
I've created a PR: #3765 |
Temp workaround for ED issue emberjs/data#3760 until the PR emberjs/data#3765 will be merged. Also change class structure to fit the current one (with a dedicated `_shouldSerializeHasMany` method).
Temp workaround for ED issue emberjs/data#3760 until PR emberjs/data#3765 is merged. Change class structure also to reflect the new one introduced earlier by ED 1.13 (with dedicated `_shouldSerializeHasMany`).
`serializeHasMany()` omits unknown relationships of pushed record rather than setting them to `undefined`.
[BUGFIX beta] Fix JSONSerializer.serializeHasMany() issue #3760
`serializeHasMany()` omits unknown relationships of pushed record rather than setting them to `undefined`. (cherry picked from commit 2dbb617)
Shouldn't this be closed because of #3765 merged? |
Here is a JSBin highlighting the two behaviors: http://emberjs.jsbin.com/rocano/8/edit?js,console,output
On the first case (post added by
createRecord
) the json is:On the 2nd case (post added by
push
) the json is:Shouldn't be the same (i.e. the 1st one)? Or is it by design to have undefined relationships on the 2nd one?
The text was updated successfully, but these errors were encountered: