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

Clone parent data hash when making nested data editable #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blt04
Copy link

@blt04 blt04 commented Oct 27, 2011

When fetching an editable hash via readEditableDataHash for a nested record, the nested hash is cloned causing it to get out of sync with its parent. The parent data hash should be cloned instead and a reference to the child hash returned.

This behavior is already present in the _lock method of SC.NestedStore. This pull request ports the code to the readEditableDataHash method of SC.Store so that editable hashes are created properly.

I noticed this when executing this sequence:

  1. Edit a nested record via a NestedStore. This correctly clones records in to the NestedStore via the _lock method.
  2. Commit changes to the parent by calling commitChanges on the NestedStore. This locks the records in the parent store.
  3. Edit the nested record again (reusing the existing NestedStore). Since the records in the parent store are now locked (not editable), the cloning is done via readEditableDataHash in SC.Store instead of _lock. This clones the data incorrectly.
  4. If I read the data hash for my nested store key, it will be different then if I read the data for my parent store key.

When fetching an editable hash via readEditableDataHash for a nested
record, make sure we clone the parent record and then return a reference
to the parent's child data.

This is similar to the behavior already present in the _lock method in
NestedStore.
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 this pull request may close these issues.

1 participant