Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: service/datastore/multiarg.go

Issue 1867963003: Add PopulateKey method to datastore. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/datastore_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/multiarg.go
diff --git a/service/datastore/multiarg.go b/service/datastore/multiarg.go
index 0e24feb041d44c069268c033cba666d3167f9781..ab335c9ef634ba1ab4fa5817ecf3b649231a229f 100644
--- a/service/datastore/multiarg.go
+++ b/service/datastore/multiarg.go
@@ -99,7 +99,7 @@ func multiArgTypePLS(et reflect.Type) multiArgType {
return slot.Addr().Interface().(PropertyLoadSaver).Load(pm)
},
setKey: func(slot reflect.Value, k *Key) {
- setKey(slot.Addr().Interface(), k)
+ PopulateKey(slot.Addr().Interface(), k)
},
}
if et.Kind() == reflect.Map {
@@ -136,7 +136,7 @@ func multiArgTypePLSPtr(et reflect.Type) multiArgType {
return slot.Interface().(PropertyLoadSaver).Load(pm)
},
setKey: func(slot reflect.Value, k *Key) {
- setKey(slot.Interface(), k)
+ PopulateKey(slot.Interface(), k)
},
}
if et.Kind() == reflect.Map {
@@ -174,7 +174,7 @@ func multiArgTypeStruct(et reflect.Type) multiArgType {
return toPLS(slot).Load(pm)
},
setKey: func(slot reflect.Value, k *Key) {
- setKey(toPLS(slot), k)
+ PopulateKey(toPLS(slot), k)
},
newElem: func() reflect.Value {
return reflect.New(et).Elem()
@@ -205,7 +205,7 @@ func multiArgTypeStructPtr(et reflect.Type) multiArgType {
return toPLS(slot).Load(pm)
},
setKey: func(slot reflect.Value, k *Key) {
- setKey(toPLS(slot), k)
+ PopulateKey(toPLS(slot), k)
},
newElem: func() reflect.Value {
return reflect.New(et)
@@ -229,7 +229,7 @@ func multiArgTypeInterface() multiArgType {
return mkPLS(slot.Elem().Interface()).Load(pm)
},
setKey: func(slot reflect.Value, k *Key) {
- setKey(slot.Elem().Interface(), k)
+ PopulateKey(slot.Elem().Interface(), k)
},
}
}
@@ -256,20 +256,6 @@ func newKeyObjErr(aid, ns string, src interface{}) (*Key, error) {
return NewKey(aid, ns, kind, sid, iid, par), nil
}
-func setKey(src interface{}, key *Key) {
- pls := getMGS(src)
- if !pls.SetMeta("key", key) {
- lst := key.LastTok()
- if lst.StringID != "" {
- pls.SetMeta("id", lst.StringID)
- } else {
- pls.SetMeta("id", lst.IntID)
- }
- pls.SetMeta("kind", lst.Kind)
- pls.SetMeta("parent", key.Parent())
- }
-}
-
func mkPLS(o interface{}) PropertyLoadSaver {
if pls, ok := o.(PropertyLoadSaver); ok {
return pls
« no previous file with comments | « service/datastore/datastore_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698