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

belongsTo association id not serialized in ember-data-1.0.0-beta.15 #2823

Closed
pierrevdb opened this Issue Feb 26, 2015 · 17 comments

Comments

Projects
None yet
5 participants
@pierrevdb

pierrevdb commented Feb 26, 2015

Hey guys

I recently tried ember-data 1.0.0-beta.15 and the belongsTo association ids aren't serialized. Reverting to 1.0.0-beta.14.1 fixes the issue.

This stack works:
Ember : 1.10.0
Ember Data : 1.0.0-beta.14.1

This stack doesn't work:
Ember : 1.10.0
Ember Data : 1.0.0-beta.15

I think this is likely related to closed issue #2801 Snapshot not being injected on beta.15

Cheers
Pierre

@leporid

This comment has been minimized.

Show comment
Hide comment
@leporid

leporid Feb 28, 2015

+1

I just spent a fair bit of time discovering the same problem. Showstopper. I will back off beta.15 in the meantime...

-------------------------------
Ember      : 1.9.0
Ember Data : 1.0.0-beta.15
Handlebars : 2.0.0
jQuery     : 1.11.2
-------------------------------

leporid commented Feb 28, 2015

+1

I just spent a fair bit of time discovering the same problem. Showstopper. I will back off beta.15 in the meantime...

-------------------------------
Ember      : 1.9.0
Ember Data : 1.0.0-beta.15
Handlebars : 2.0.0
jQuery     : 1.11.2
-------------------------------
@wecc

This comment has been minimized.

Show comment
Hide comment
@wecc

wecc Feb 28, 2015

Contributor

Are you using custom adapters/serializers that calls serialize() with a record instead of a snapshot? (as was the case of #2801) If not, there shouldn't be code paths in ED that ends up with a record instead of snapshot in serialize(), a failing JSBin would be awesome for troubleshooting.

Contributor

wecc commented Feb 28, 2015

Are you using custom adapters/serializers that calls serialize() with a record instead of a snapshot? (as was the case of #2801) If not, there shouldn't be code paths in ED that ends up with a record instead of snapshot in serialize(), a failing JSBin would be awesome for troubleshooting.

@pierrevdb

This comment has been minimized.

Show comment
Hide comment
@pierrevdb

pierrevdb Mar 1, 2015

Hi @wecc

We're not using any custom adapters or serializers - just the stock ActiveModelAdapter.

With regards to #2801, I just meant that this is likely also related to the move to snapshots. This assumption is, admittedly, not based on any digging in the code as I haven't really had the time to do so.

Cheers
Pierre

pierrevdb commented Mar 1, 2015

Hi @wecc

We're not using any custom adapters or serializers - just the stock ActiveModelAdapter.

With regards to #2801, I just meant that this is likely also related to the move to snapshots. This assumption is, admittedly, not based on any digging in the code as I haven't really had the time to do so.

Cheers
Pierre

@wecc

This comment has been minimized.

Show comment
Hide comment
@wecc

wecc Mar 3, 2015

Contributor

@pierrevdb would you be able to replicate the issue in a JSBin?

Contributor

wecc commented Mar 3, 2015

@pierrevdb would you be able to replicate the issue in a JSBin?

@bmac

This comment has been minimized.

Show comment
Hide comment
@bmac

bmac Mar 6, 2015

Member

Ping @pierrevdb any chance you could replicate this in a JSBin? Here is an example bin to get you started: http://emberjs.jsbin.com/qovara/2/edit?html,js,output

Member

bmac commented Mar 6, 2015

Ping @pierrevdb any chance you could replicate this in a JSBin? Here is an example bin to get you started: http://emberjs.jsbin.com/qovara/2/edit?html,js,output

@pierrevdb

This comment has been minimized.

Show comment
Hide comment
@pierrevdb

pierrevdb Mar 7, 2015

Sorry for the delayed response - been a little busy.

I'll try to make some time this week.

pierrevdb commented Mar 7, 2015

Sorry for the delayed response - been a little busy.

I'll try to make some time this week.

@jordpo

This comment has been minimized.

Show comment
Hide comment
@jordpo

jordpo Mar 13, 2015

I'm also running into this issue. It's working fine in beta v14.1. does anyone have any suggestions for a workaround? thanks!

jordpo commented Mar 13, 2015

I'm also running into this issue. It's working fine in beta v14.1. does anyone have any suggestions for a workaround? thanks!

@wecc

This comment has been minimized.

Show comment
Hide comment
@wecc

wecc Mar 14, 2015

Contributor

@jordpo If you'd be able to reproduce the issue in a JSBin it would be great. Makes it so much easier to troubleshoot.

If you're using custom adapters and/or serializers that manually calls serialize methods you need to make sure that the serialize methods receives a snapshot instead of a model. This will be improved upon shortly as we're making sure adapters are receiving snapshots instead of models in the first place. But that is currently not the case.

If you're only using default adapters/serializers there's probably a bug somewhere that needs to be fixed. A failing JSBin would be awesome so we can identify the bug.

Contributor

wecc commented Mar 14, 2015

@jordpo If you'd be able to reproduce the issue in a JSBin it would be great. Makes it so much easier to troubleshoot.

If you're using custom adapters and/or serializers that manually calls serialize methods you need to make sure that the serialize methods receives a snapshot instead of a model. This will be improved upon shortly as we're making sure adapters are receiving snapshots instead of models in the first place. But that is currently not the case.

If you're only using default adapters/serializers there's probably a bug somewhere that needs to be fixed. A failing JSBin would be awesome so we can identify the bug.

@jordpo

This comment has been minimized.

Show comment
Hide comment
@jordpo

jordpo Mar 15, 2015

@wecc - here you go:

http://emberjs.jsbin.com/kivetopeqa/1/edit?html,js,output

I believe this replicates the issue that I am experiencing. Specifically in my case, I am using a select view to dynamically set a belongsTo relationship. While playing around with the JSBin, I noticed that the belongsTo relationship somehow disappears when I call save on the model.

I, too, am using the ActiveModelSerializer adapter and can confirm that the organizationId is not serialized and sent to the server at all.

Let me know if you need anything else.

jordpo commented Mar 15, 2015

@wecc - here you go:

http://emberjs.jsbin.com/kivetopeqa/1/edit?html,js,output

I believe this replicates the issue that I am experiencing. Specifically in my case, I am using a select view to dynamically set a belongsTo relationship. While playing around with the JSBin, I noticed that the belongsTo relationship somehow disappears when I call save on the model.

I, too, am using the ActiveModelSerializer adapter and can confirm that the organizationId is not serialized and sent to the server at all.

Let me know if you need anything else.

@jordpo

This comment has been minimized.

Show comment
Hide comment
@jordpo

jordpo Mar 15, 2015

Yeah looking at it closer, the JSBin is just resetting the model to its original fixture state. So not quite the exact replication of the issue that I am facing..

jordpo commented Mar 15, 2015

Yeah looking at it closer, the JSBin is just resetting the model to its original fixture state. So not quite the exact replication of the issue that I am facing..

@jordpo

This comment has been minimized.

Show comment
Hide comment
@jordpo

jordpo Mar 15, 2015

Here is an updated JSBin using the ActiveModelAdapter. Can't seem to replicate the issue. Will look at it closer tomorrow when I get my local development running again.

http://emberjs.jsbin.com/kivetopeqa/1/edit?html,js,output

jordpo commented Mar 15, 2015

Here is an updated JSBin using the ActiveModelAdapter. Can't seem to replicate the issue. Will look at it closer tomorrow when I get my local development running again.

http://emberjs.jsbin.com/kivetopeqa/1/edit?html,js,output

@wecc

This comment has been minimized.

Show comment
Hide comment
@wecc

wecc Mar 15, 2015

Contributor

@jordpo Thanks!

I think this is the select tripping you up. Replacing value=model.organization.content with selection=model.organization actually gives you the right value when saving (if you give your organization IDs - do push instead of createRecord). The select is known to have some weirdness and it's being rewritten. Would it be possible to try to replicate this issue without using the select?

Contributor

wecc commented Mar 15, 2015

@jordpo Thanks!

I think this is the select tripping you up. Replacing value=model.organization.content with selection=model.organization actually gives you the right value when saving (if you give your organization IDs - do push instead of createRecord). The select is known to have some weirdness and it's being rewritten. Would it be possible to try to replicate this issue without using the select?

@jordpo

This comment has been minimized.

Show comment
Hide comment
@jordpo

jordpo Mar 16, 2015

@wecc - thank you! Yeah it does indeed appear our issue stems from the select. Using selection=model.organization does fix the issue of setting the organizationId on the serializer. However it is not showing the current value in the select now, without specifically indicating 'content' in the selection (selection=model.organization.content). Here is the my entire select view.

          {{view 'select'
            prompt='--Select organization--'
            selection=model.organization
            content=organizations
            optionLabelPath='content.name' optionValuePath='content'}}

No worries if this no longer belongs in this thread. I'll do some more digging on my end. But it doesn't appear to be an adapter issue as initially thought.

jordpo commented Mar 16, 2015

@wecc - thank you! Yeah it does indeed appear our issue stems from the select. Using selection=model.organization does fix the issue of setting the organizationId on the serializer. However it is not showing the current value in the select now, without specifically indicating 'content' in the selection (selection=model.organization.content). Here is the my entire select view.

          {{view 'select'
            prompt='--Select organization--'
            selection=model.organization
            content=organizations
            optionLabelPath='content.name' optionValuePath='content'}}

No worries if this no longer belongs in this thread. I'll do some more digging on my end. But it doesn't appear to be an adapter issue as initially thought.

@wecc

This comment has been minimized.

Show comment
Hide comment
@wecc

wecc Mar 18, 2015

Contributor

@jordpo 👍

@pierrevdb Is your issue related to the one described above or might it be something else?

Contributor

wecc commented Mar 18, 2015

@jordpo 👍

@pierrevdb Is your issue related to the one described above or might it be something else?

@pierrevdb

This comment has been minimized.

Show comment
Hide comment
@pierrevdb

pierrevdb Mar 19, 2015

@wecc

My issue looks very similar: the content of a select view set to the result of a promise (store#find) which required selection to be set to xxx.content. If the selection is set to xxx it doesn't change xxx when you select a different option from the drop-down. I'm using ObjectController so I'm not referencing the model directly (xxx instead of model.xxx).

I checked the model in the Ember explorer as well as manually in the debugger, and the value of xxx was set correctly prior to serialization but was not serialized.

I've subsequently changed the way select views are populated for other reasons, but haven't had a chance to try beta15 again. I'll give it a try and let you know when I find a gap somewhere.

pierrevdb commented Mar 19, 2015

@wecc

My issue looks very similar: the content of a select view set to the result of a promise (store#find) which required selection to be set to xxx.content. If the selection is set to xxx it doesn't change xxx when you select a different option from the drop-down. I'm using ObjectController so I'm not referencing the model directly (xxx instead of model.xxx).

I checked the model in the Ember explorer as well as manually in the debugger, and the value of xxx was set correctly prior to serialization but was not serialized.

I've subsequently changed the way select views are populated for other reasons, but haven't had a chance to try beta15 again. I'll give it a try and let you know when I find a gap somewhere.

@wecc

This comment has been minimized.

Show comment
Hide comment
@wecc

wecc Jun 2, 2015

Contributor

@pierrevdb did you get a chance to try out a more recent beta? could this be closed?

Contributor

wecc commented Jun 2, 2015

@pierrevdb did you get a chance to try out a more recent beta? could this be closed?

@pierrevdb

This comment has been minimized.

Show comment
Hide comment
@pierrevdb

pierrevdb Jun 3, 2015

@wecc I think you should close this for now.

I haven't had a chance to try a new beta but am planning on trying the latest in the next week or so but, since I changed the way I use select view,s the issue wouldn't be immediately obvious after an upgrade so I would need to spend some time to test again. If I find a problem I can always open a new issue for the latest beta.

Thanks for following up.

pierrevdb commented Jun 3, 2015

@wecc I think you should close this for now.

I haven't had a chance to try a new beta but am planning on trying the latest in the next week or so but, since I changed the way I use select view,s the issue wouldn't be immediately obvious after an upgrade so I would need to spend some time to test again. If I find a problem I can always open a new issue for the latest beta.

Thanks for following up.

@pierrevdb pierrevdb closed this Jun 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment