Skip to content
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

[BUGFIX release-1-13] Disable polymorphic deserialization when a mode… #3725

Merged
merged 1 commit into from
Sep 10, 2015

Conversation

XrXr
Copy link
Contributor

@XrXr XrXr commented Sep 3, 2015

…l expects a type attribute

b7f7b7a introduced a bug where if there is a type key in a payload that is part
of an array, it would be used for polymorphic deserialization even when the
model expects an attribute that is named "type".

Interestingly, for such payloads, arrayHash passed into normalizeArray() in
rest-serializer.js contains Ember.Object instances as opposed to plain objects.
This causes the code to throw, since hash.type would be a computed property
in that case instead of a string that dasherize expects. This is probably because
of extending from JSONAPISerializer.

Fixes #3702.

It probably also fixes #3724, but needs a port to 2.0

@XrXr XrXr force-pushed the disable-polymorphic-for-type-atrr branch 2 times, most recently from 4f4e4b8 to da4c68c Compare September 3, 2015 18:30
…l expects a type attribute

b7f7b7a introduced a bug where if there is a type key in a payload that is part
of an array, it would be used for polymorphic deserialization even when the
model expects an attribute that is named "type".

Interestingly, for such payloads, `arrayHash` passed into `normalizeArray()` in
rest-serializer.js contains Ember.Object instances as opposed to plain objects.
This causes the code to throw, since `hash.type` would be a computed property
in that case. This is probably because of extending from JSONAPISerializer.
@XrXr XrXr force-pushed the disable-polymorphic-for-type-atrr branch from da4c68c to a117f01 Compare September 3, 2015 18:31
@bmac
Copy link
Member

bmac commented Sep 7, 2015

Thanks @XrXr. This pr looks great. @wecc or @igorT could you also review this?

@wecc
Copy link
Contributor

wecc commented Sep 8, 2015

LGTM 👍

bmac added a commit that referenced this pull request Sep 10, 2015
[BUGFIX release-1-13] Disable polymorphic deserialization when a mode…
@bmac bmac merged commit 81726b2 into emberjs:release-1-13 Sep 10, 2015
@XrXr XrXr deleted the disable-polymorphic-for-type-atrr branch September 10, 2015 18:11
bmac added a commit that referenced this pull request Sep 21, 2015
Port pr #3725 to the release 2.0 branch
@jmurphyau
Copy link
Contributor

Something worth considering that looks like it could still be an issue: consider the scenario where the a Product has a productType attribute but it's coming from the server as type - the serializer would know to pull the payload datas type property into the models productType attribute.

It looks like primaryHasTypeAttribute will be false here a user may hit this same issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants