sproutcore/sproutcore-datastore — pull request #16 by blt04 (2011-10-27 00:34:50+00:00)
Title: Clone parent data hash when making nested data editable

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.