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

Async relations are deleted after findRecord query (2.13.0) #4967

Closed
jurgenwerk opened this issue May 4, 2017 · 4 comments
Closed

Async relations are deleted after findRecord query (2.13.0) #4967

jurgenwerk opened this issue May 4, 2017 · 4 comments

Comments

@jurgenwerk
Copy link

jurgenwerk commented May 4, 2017

I'm experiencing some odd behaviour which didn't occur in the previous version I upgraded from (2.9.0). I'm using Ember 2.12.1 and Ember-Data 2.13.0.

I have two models, UrlGroup and Url.

They are related (sorry for CoffeeScript):

UrlGroup = DS.Model.extend
  urls: DS.hasMany('url', async: false)
Url = DS.Model.extend
  urlGroup: DS.belongsTo('url-group', async: true)

At some point in my app, I load the urls into a urlGroup, like this:

@store.query('url', group_id: urlGroup.id).then (urls) =>
  urlGroup.set('urls', urls)

This works fine and I can operate with {{urlGroup.urls}} just fine and list them in my template.

But some time later in the app, I do this request:

this.store.findRecord('url', properties.urlId).then((url) => {
  someObject.set('url', url);
 });

And this causes my urlGroup.urls to lose whatever it contained before (multiple urls), and leave it containing only the url fetched with the findRecord.

I'm using the ActiveModelAdapter, and this is the response from findRecord:

{"url: { id: 41104, url_type: "google", ... } }

As said, this worked in the previous versions and this current behaviour doesn't seem normal to me. Is this expected?

@jurgenwerk
Copy link
Author

jurgenwerk commented May 6, 2017

I'm seeing regressions throughout the whole of my app because of this issue. Basically, whenever I call save() or destroyRecord() on a model that is in a hasMany relation from some other other model, this parent model loses every other model in the hasMany relation except for the record the operation was called upon.

Surely that can't be normal?

@mazondo
Copy link

mazondo commented May 10, 2017

Has anyone found a solution for this? I'm not sure if I should investigate a work around on my side or dive into taking a look at it in Ember Data to see if I can submit a PR. Is this an intentional change with 2.13?

@jurgenwerk
Copy link
Author

I find it very odd there are just two of us with this issue 😳. I had to rewrite several parts of my app, and I can't find nothing in recent release notes that could attribute to this (breaking) change.

@runspired
Copy link
Contributor

This should be fixed by 3.2 beta. Possibly fixed in 3.1 as well, I'm not 100% sure off the top of my head where the cut was made.

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