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

Unified Diff: service/datastore/datastore.go

Issue 1516173002: Fix error message from KeyForObj when passing an invalid struct. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: remove accidental extra test Created 5 years 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
Index: service/datastore/datastore.go
diff --git a/service/datastore/datastore.go b/service/datastore/datastore.go
index 6ded9554dbc2d809f932341baf424113e6a400b6..a6ae3e9e3509e2a9a0ab6bde7e90cb859d358699 100644
--- a/service/datastore/datastore.go
+++ b/service/datastore/datastore.go
@@ -62,8 +62,8 @@ func (d *datastoreImpl) Run(q *Query, cbIface interface{}) error {
if firstArg == typeOfKey {
isKey = true
} else {
- mat = parseArg(firstArg)
- badSig = !mat.valid || mat.newElem == nil
+ mat = parseArg(firstArg, false)
+ badSig = mat.newElem == nil
}
} else {
badSig = true
@@ -143,7 +143,7 @@ func (d *datastoreImpl) GetAll(q *Query, dst interface{}) error {
slice := v.Elem()
mat := parseMultiArg(slice.Type())
- if !mat.valid || mat.newElem == nil {
+ if mat.newElem == nil {
return fmt.Errorf("invalid GetAll input type: %T", dst)
}
@@ -226,9 +226,6 @@ func (d *datastoreImpl) Delete(key *Key) (err error) {
func (d *datastoreImpl) GetMulti(dst interface{}) error {
slice := reflect.ValueOf(dst)
mat := parseMultiArg(slice.Type())
- if !mat.valid {
- return fmt.Errorf("invalid GetMulti input type: %T", dst)
- }
keys, pms, err := mat.GetKeysPMs(d.aid, d.ns, slice, true)
if err != nil {
@@ -254,9 +251,6 @@ func (d *datastoreImpl) GetMulti(dst interface{}) error {
func (d *datastoreImpl) PutMulti(src interface{}) error {
slice := reflect.ValueOf(src)
mat := parseMultiArg(slice.Type())
- if !mat.valid {
- return fmt.Errorf("invalid PutMulti input type: %T", src)
- }
keys, vals, err := mat.GetKeysPMs(d.aid, d.ns, slice, false)
if err != nil {

Powered by Google App Engine
This is Rietveld 408576698