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

Relationship on sibling records lost after saving new record with the same relationship #5807

Closed
MichalBryxi opened this issue Dec 25, 2018 · 3 comments

Comments

@MichalBryxi
Copy link
Contributor

MichalBryxi commented Dec 25, 2018

Reproduction

  • A Twiddle - all the details are described in the application template.

Description

  1. Relationships: visit hasMany sells. Sell belongsTo item.
  2. App loads "visit" with included data: "sells" and "sells.item".
  3. User clicks on the button that will create new sell. Sell has information about an item and respective visit. This sell will use item that is already linked to another sell.
    Server saves the data and sends back JSON-API response describing the saved data. Exactly at that moment, all the already existing sells will lose their relationship link to their item - this is unexpected behaviour. It works with any number of sells. All the already loaded sells will lose the relationship link.
  • I'm using gem 'jsonapi-resources', '0.9.2' to generate my data.
  • The expected behaviour is that no sell will lose the relationship to the item after creating new sell.

Versions

First known problematic version:

  "ember": "3.4.3",
  "ember-data": "3.5.0",

Tested versions of ember-data:

  • 3.4.2 - no bug
  • 3.4.4 - no bug
  • 3.5.0 - bug present
  • 3.6.0 - bug present
@BryanCrotaz
Copy link
Contributor

Try this with PR #5806 - I've done some work with preserving values in hasMany relationships

@MichalBryxi
Copy link
Contributor Author

Thanks @BryanCrotaz. Tried to convert the twiddle to ember-cli app, but looks like your branch won't help with this problem. The export is here if you want to have a look that I'm not doing something silly: https://drive.google.com/file/d/17a1PbH1dbY4_Wr_ClvRA2I6nFgxuGnfU/view?usp=sharing

@runspired
Copy link
Contributor

This is fixed in 3.10+ in the twiddle above.

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