-
-
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
Embedded records mixin should use the correct serialization key when deserialize configuration is set, Fixes #2556 #2790
Embedded records mixin should use the correct serialization key when deserialize configuration is set, Fixes #2556 #2790
Conversation
Hit this today, thanks for the fix! |
keyForRelationship: function(key, type) { | ||
if (this.hasDeserializeRecordsOption(key)) { | ||
keyForRelationship: function(key, type, method) { | ||
if (method === undefined) { method = 'deserialize'; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the convention is to put the conditional body on its own line so its easier to inset a breakpoint if needed,
For symmetry, I'd like to see the 'deserialize' argument included on the |
@pixelhandler and @igorT would one of you like to review this pr since you have more familiarity with the EmbeddedMixin and (presumably) with ActiveRecord? |
@bmac I can take a look in the next day or two |
2b13553
to
5644d84
Compare
@bmac done and done! |
keyForRelationship: function(key, type) { | ||
if (this.hasDeserializeRecordsOption(key)) { | ||
keyForRelationship: function(key, type, method) { | ||
if (method === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed anymore right?
Thanks for the PR! Looks pretty good. If we are gonna add 'serialize'/'deserialize', could you do it throughout all the serializers and not just the EmbeddedRecords one? |
@igorT I can certainly do that, but won't that cause jsHint warnings about unused arguments in the |
5644d84
to
319acc3
Compare
@igorT or were you thinking of just adding the argument to the call-sites and since we only happen to use it in the |
319acc3
to
f8902bd
Compare
@igorT I went with the latter. Let me know if I can do anything else! |
f8902bd
to
1bbf895
Compare
@igorT is there anything remaining to get this in before beta 16 goes out? |
@agrobbin This issue was discussed in the last Ember Data meeting and it was decided that if this change is made for |
1bbf895
to
c819aa8
Compare
@bmac 👍 just pushed up a second commit to this branch, happy to squash them into 1 assuming you like how this looks! |
Seems good 👍 To support getting the right key, it seems necessary to know whether the key will be used to serialize or deserialize, nice. |
…deserialize configuration is set When extending the `DS.EmbeddedRecordsMixin`, if you configure a relationship as `{ serialize: 'id', deserialize: 'records' }`, it won't actually pay attention to the `serialize: 'id'` option, but use the `deserialize: 'records'` option.
c819aa8
to
5bfda83
Compare
Squashed! |
…rialize-ids Embedded records mixin should use the correct serialization key when deserialize configuration is set, Fixes #2556
Thank you @agrobbin |
No problem! |
This is my first attempted contribution to Ember Data, so if I'm approaching anything the wrong way, please let me know!
When extending the
DS.EmbeddedRecordsMixin
, if you configure abelongsTo
relationship as{ serialize: 'id', deserialize: 'records' }
, it won't actually pay attention to theserialize: 'id'
option, but use thedeserialize: 'records'
option. This is because ofserializeBelongsTo
and the reimplementation ofkeyForRelationship
, which notices thedeserialize
option instead of theserialize
option.Fixes #2556.