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

_normalizePolymorphicRecord in RESTSerializer breaks old REST API when model has type attribute #3724

Closed
iammer opened this issue Sep 3, 2015 · 1 comment

Comments

@iammer
Copy link

iammer commented Sep 3, 2015

I am using ember-data 2.0.0

When using the old REST API, if a model has an attribute named type which can have a value that matches the name of another model, then the model instance may be loaded with the wrong model.

_normalizePolymorphicRecord tries to detect if a payload is using JSON API or REST API, by checking if the hash has a type attribute that matches a model name. But, it is possible for this to occur when using the REST API as well. So, payloads from the REST API are sometimes erroneously parsed as JSON API payloads, causing them to be loaded into the store with the wrong model.

Since I don't use the JSON API, I have worked around this issue in my application by adding the below to my application serializer.

    _normalizePolymorphicRecord: function (store, hash, prop, modelClass, serializer) {
        return serializer.normalize(modelClass, hash, prop);
    }
@pangratz
Copy link
Member

pangratz commented Jan 2, 2016

I think this issue can be closed since the fix merged in #3725 has been backported to master in #3788...

@bmac bmac closed this as completed Jan 2, 2016
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

No branches or pull requests

3 participants