VOL-1283: Fixed callback execution consistency for all proxy levels
- Callbacks are executed at any proxy levels
- Uncovered some issues with the base children fields structure
- cleaned up the root/node structures
- Ensure that a get command returns a clone.
Change-Id: Ic2cd5420c29332bd9b5d6f303a7fd9d0d0ccaf06
diff --git a/db/model/persisted_revision.go b/db/model/persisted_revision.go
index 774b77e..b62c569 100644
--- a/db/model/persisted_revision.go
+++ b/db/model/persisted_revision.go
@@ -34,7 +34,7 @@
func NewPersistedRevision(branch *Branch, data interface{}, children map[string][]Revision) Revision {
pr := &PersistedRevision{}
- pr.kvStore = branch.Node.root.KvStore
+ pr.kvStore = branch.Node.Root.KvStore
pr.Revision = NewNonPersistedRevision(branch, data, children)
pr.Finalize()
return pr
@@ -64,7 +64,9 @@
for fieldName, children := range pr.GetChildren() {
hashes := []string{}
for _, rev := range children {
- hashes = append(hashes, rev.GetHash())
+ if rev != nil {
+ hashes = append(hashes, rev.GetHash())
+ }
}
childrenHashes[fieldName] = hashes
}
@@ -119,7 +121,7 @@
var children []Revision
for _, childHash := range childrenHashes[fieldName] {
childNode := node.MakeNode(reflect.New(child.ClassType).Elem().Interface(), "")
- childNode.LoadLatest(kvStore, childHash)
+ childNode.LoadLatest(childHash)
childRev := childNode.Latest()
children = append(children, childRev)
}