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

Bugfix for wrong hasMany relationship state in scenario of sideposting with lid #7126

Merged
merged 1 commit into from
Oct 9, 2020

Conversation

andreyfel
Copy link
Contributor

@andreyfel andreyfel commented Apr 15, 2020

The issue appeared in a sideposting scenario:

  • model A has has many relationship to model B.

  • instance of model A and instance of model B are created on the client,

  • model A is saved along with model B sent in include section of payload; the linking is done through lid

  • server persisted both models and sent the response with server-generated id along with lid sent by the client.

  • when hasMany.updateData() was called while the response payload was pushed to the store it couldn't match the record which was already in the store with the record data contained in the relationship data because lid was omitted.

@andreyfel andreyfel force-pushed the sideposting-with-lid branch from 1a48750 to 67b597d Compare April 16, 2020 14:26
@andreyfel andreyfel force-pushed the sideposting-with-lid branch 2 times, most recently from 009c01f to 856f6eb Compare October 6, 2020 14:27
@andreyfel andreyfel changed the title Add failing test for the case of sideposting with lid Bugfix for wrong hasMany relationship state in scenario of sideposting with lid Oct 6, 2020
@andreyfel andreyfel force-pushed the sideposting-with-lid branch from 856f6eb to 9fae340 Compare October 6, 2020 14:33
@snewcomer snewcomer added the Bug label Oct 7, 2020
Copy link
Contributor

@snewcomer snewcomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was probably the result of some good/deep investigation. Great find here.

The issue appeared in the sideposting scenario:

- model A has has many relationship to model B.

- instance of model A and instance of model B are created on the client,

- model A is saved along with model B sent in `include` section of
  payload; the linking is done through `lid`

- server persisted both models and sent the response with
  server-generated `id` along with `lid` sent by the client.

- when hasMany.updateData() was called while the response payload was
  pushed to the store it couldn't match the record which was already in
  the store with the record data contained in the relationship data
  because `lid` was omitted.

Add a test which ensures that the hasMany() relationship has correct
status in the sideposting with lid scenario.
@andreyfel andreyfel force-pushed the sideposting-with-lid branch from 9fae340 to 294186f Compare October 7, 2020 08:44
@andreyfel
Copy link
Contributor Author

@snewcomer yeah, I've spent a day debugging the ember-data internals :)

I've squashed the commits so it is easier to backport the fix to LTS and other branches.

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

Successfully merging this pull request may close these issues.

4 participants