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

Unified Diff: service/datastore/multiarg.go

Issue 1289323002: Fix miscellaneous prod bugs. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Rebase. Created 5 years, 4 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') | service/datastore/pls.go » ('j') | 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 3efa1493df86692ed1947c2985ba17e753f54b46..8dca99c46aec59624dd5f704a22654b0a5e3722b 100644
--- a/service/datastore/multiarg.go
+++ b/service/datastore/multiarg.go
@@ -214,11 +214,11 @@ func multiArgTypeInterface() multiArgType {
return newKeyObjErr(nk, slot.Elem().Interface())
},
getPM: func(slot reflect.Value) (PropertyMap, error) {
- pls, _ := mkPLSName(slot.Elem().Interface())
+ pls := mkPLS(slot.Elem().Interface())
return pls.Save(true)
},
setPM: func(slot reflect.Value, pm PropertyMap) error {
- pls, _ := mkPLSName(slot.Elem().Interface())
+ pls := mkPLS(slot.Elem().Interface())
return pls.Load(pm)
},
setKey: func(slot reflect.Value, k Key) {
@@ -228,15 +228,15 @@ func multiArgTypeInterface() multiArgType {
}
func newKeyObjErr(nk newKeyFunc, src interface{}) (Key, error) {
- pls, name := mkPLSName(src)
+ pls := mkPLS(src)
if key, _ := pls.GetMetaDefault("key", nil).(Key); key != nil {
return key, nil
}
// get kind
- kind := pls.GetMetaDefault("kind", name).(string)
+ kind := pls.GetMetaDefault("kind", "").(string)
if kind == "" {
- return nil, fmt.Errorf("unable to extract $kind from %v", src)
+ return nil, fmt.Errorf("unable to extract $kind from %T", src)
}
// get id - allow both to be default for default keys
@@ -250,7 +250,7 @@ func newKeyObjErr(nk newKeyFunc, src interface{}) (Key, error) {
}
func setKey(src interface{}, key Key) {
- pls, _ := mkPLSName(src)
+ pls := mkPLS(src)
if pls.SetMeta("key", key) == ErrMetaFieldUnset {
if key.StringID() != "" {
pls.SetMeta("id", key.StringID())
@@ -262,14 +262,9 @@ func setKey(src interface{}, key Key) {
}
}
-func mkPLSName(o interface{}) (PropertyLoadSaver, string) {
- if pls, ok := o.(*structPLS); ok {
- return pls, pls.o.Type().Name()
- }
+func mkPLS(o interface{}) PropertyLoadSaver {
if pls, ok := o.(PropertyLoadSaver); ok {
- return pls, ""
+ return pls
}
- pls := GetPLS(o)
- name := pls.(*structPLS).o.Type().Name()
- return pls, name
+ return GetPLS(o)
}
« no previous file with comments | « service/datastore/datastore_test.go ('k') | service/datastore/pls.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698