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

Snapshot returns deleted ids in hasMany call #3081

Closed
aaronbhansen opened this issue May 18, 2015 · 2 comments · Fixed by #3170
Closed

Snapshot returns deleted ids in hasMany call #3081

aaronbhansen opened this issue May 18, 2015 · 2 comments · Fixed by #3170

Comments

@aaronbhansen
Copy link

We have a situation where we delete a record, and then the main model is saved (that contains a hasMany relation for the record that was just deleted). When it goes to serialize the hasMany ids in that relation, the deleted records (but not yet saved), are included in that list.

It seems like if a record is marked as deleted, it shouldn't be included in the snapshot hasMany along with the live records. The snapshot when gathering the ids doesn't do any filtering, but feels like it should check isDeleted before including it in the snapshot.

https://github.com/emberjs/data/blob/v1.0.0-beta.17/packages/ember-data/lib/system/snapshot.js#L276

https://www.dropbox.com/s/lijhqe0gy37t0q7/Screenshot%202015-05-18%2016.31.29.png?dl=0

@igorT
Copy link
Member

igorT commented May 19, 2015

That shouldn't be happening, we remove records from their opposite relationships once they are deleted. Could you maybe reproduce in a jsbin? Can you post your model definitions?

@aaronbhansen
Copy link
Author

Still trying to replicate this in a jsbin, but haven't been able to yet. Here is another screen shot right after deleting a reward selections. I had 3, deleted 1, and then backer shows 2 if I view the relation. When I view the snapshot, it shows 3.

https://www.dropbox.com/s/43eex2hmphqtnhq/Screenshot%202015-05-19%2014.58.36.png?dl=0

A screen shot of the relations current state.

https://www.dropbox.com/s/67fm63rn4oj873d/Screenshot%202015-05-19%2015.06.49.png?dl=0

It is a pretty standard relation. We have a backer model that has multiple reward selections. The manyArray has the correct information, but members doesn't.

ianstarz pushed a commit to ianstarz/data that referenced this issue Jun 3, 2015
Even though we remove records from their opposite relationships once they
are deleted, this commit places this functionality under test and ensures
that only non deleted records are returned from snapshot.belongsTo() and
snapshot.hasMany().

Closes emberjs#3081
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 a pull request may close this issue.

2 participants