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

[Store] Documents might contain stale values after update #1472

Open
Merkur39 opened this issue May 13, 2024 · 0 comments
Open

[Store] Documents might contain stale values after update #1472

Merkur39 opened this issue May 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working discussion Discuss about a particular subject to take a decision

Comments

@Merkur39
Copy link
Member

Merkur39 commented May 13, 2024

Today, documents in the Store are updated in this way:

const merged = {
  ...prevDocument,
  ...nextDocument
}

if (prevDocument.relationships || nextDocument.relationships) {
  merged.relationships = {
    ...prevDocument.relationships,
    ...nextDocument.relationships
  }
}

NB: in an object literal, the spread syntax enumerates the properties of an object and adds the key-value pairs to the object being created. But at the first level*

This approach allows you to update the document in the Store without necessarily having to pass the whole document to it (nextDocument), but poses a problem when you want to delete an attribute at the second level (or at the second level of relationships).

This change was made during this PR: #342

  1. We'll have to see why this problem has been corrected here and not elsewhere.
  2. We probably shouldn't have a spread, and replace the Store document with the new one. But we need to make sure we always have the full document in nextDocument.
@Merkur39 Merkur39 added bug Something isn't working discussion Discuss about a particular subject to take a decision labels May 13, 2024
@Merkur39 Merkur39 self-assigned this May 13, 2024
@paultranvan paultranvan changed the title [Store] Updating corrupted documents [Store] Documents might contain stale values after update May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion Discuss about a particular subject to take a decision
Projects
None yet
Development

No branches or pull requests

1 participant