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

[Bug] Polymorphic won't work #3547

Closed
marcemira opened this issue Jul 15, 2015 · 8 comments
Closed

[Bug] Polymorphic won't work #3547

marcemira opened this issue Jul 15, 2015 · 8 comments
Labels
🏷️ bug This PR primarily fixes a reported issue

Comments

@marcemira
Copy link

Hello, I'm trying to work with polymorphic relations, the problem seems to be that it ignores the payload "type" attribute, It will use the payload primary key as modelType instead.

Here is a JsBin: http://emberjs.jsbin.com/wilavu/edit?html,js,output

Let me know what am I doing wrong, if is not a bug I'm really sorry, please close this issue.

Thanks

@bmac
Copy link
Member

bmac commented Jul 15, 2015

This is a bug.

It looks like the issue is the serializer is calling normalize using the polymorphic superclass's serializer instead of the serializer for the specific record type that is being returned.

https://github.com/emberjs/data/blob/master/packages/ember-data/lib/serializers/rest-serializer.js#L242

@bmac bmac added the Bug label Jul 15, 2015
@marcemira
Copy link
Author

👍 thanks!

@SeyZ
Copy link

SeyZ commented Jul 15, 2015

👍

@marcemira
Copy link
Author

What about this RFCS?

@wecc
Copy link
Contributor

wecc commented Jul 15, 2015

@marcemira I think that RFC will solve this bug. And I suspect it will be very hard to fix until then. We can make it use the correct serializer but that's only one part of it.

@marcemira
Copy link
Author

@wecc In order to continue working on my app, can I do something to patch it until then? What would you suggest me to do?. Thanks man

@wecc
Copy link
Contributor

wecc commented Jul 15, 2015

Hm, I though this was about doing store.findAll('base-type') with polymorphic results... polymorphic relationships should work. We should be able to solve this... I'm surprised that we don't have tests for this already.

@marcemira
Copy link
Author

Hello @wecc can I help in any way? How does the payload is supposed to look like today(assuming it's working)?. I think it's has something to do with ED not serializing the payload when it doesn't represent a primary type, It just returns an empty serialized data... isn't that correct? Thanks

bmac added a commit to bmac/data that referenced this issue Jul 23, 2015
bmac added a commit to bmac/data that referenced this issue Aug 20, 2015
bmac added a commit to bmac/data that referenced this issue Aug 20, 2015
bmac added a commit to bmac/data that referenced this issue Aug 20, 2015
bmac added a commit that referenced this issue Aug 20, 2015
…pe when normalizing async relationships.

Closes #3547

(cherry picked from commit b7f7b7a)
bmac added a commit that referenced this issue Aug 20, 2015
…pe when normalizing async relationships.

Closes #3547

(cherry picked from commit b7f7b7a)

Conflicts:
	packages/ember-data/lib/serializers/rest-serializer.js
	packages/ember-data/tests/integration/serializers/rest-serializer-test.js
@runspired runspired added 🏷️ bug This PR primarily fixes a reported issue and removed Bug labels Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bug This PR primarily fixes a reported issue
Projects
None yet
Development

No branches or pull requests

5 participants