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

Side by Side Diff: service/datastore/pls_impl.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: Fix GetMetaDefault silliness 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // HEAVILY adapted from github.com/golang/appengine/datastore 5 // HEAVILY adapted from github.com/golang/appengine/datastore
6 6
7 package datastore 7 package datastore
8 8
9 import ( 9 import (
10 "fmt" 10 "fmt"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 } 346 }
347 if needKind { 347 if needKind {
348 if _, ok := p.c.byMeta["kind"]; !ok { 348 if _, ok := p.c.byMeta["kind"]; !ok {
349 ret["$kind"] = []Property{MkPropertyNI(p.getDefaultKind( ))} 349 ret["$kind"] = []Property{MkPropertyNI(p.getDefaultKind( ))}
350 } 350 }
351 } 351 }
352 return ret 352 return ret
353 } 353 }
354 354
355 func (p *structPLS) GetMetaDefault(key string, def interface{}) interface{} {
356 return GetMetaDefaultImpl(p.GetMeta, key, def)
357 }
358
359 func (p *structPLS) SetMeta(key string, val interface{}) (err error) { 355 func (p *structPLS) SetMeta(key string, val interface{}) (err error) {
360 if err = p.Problem(); err != nil { 356 if err = p.Problem(); err != nil {
361 return 357 return
362 } 358 }
363 idx, ok := p.c.byMeta[key] 359 idx, ok := p.c.byMeta[key]
364 if !ok { 360 if !ok {
365 return ErrMetaFieldUnset 361 return ErrMetaFieldUnset
366 } 362 }
367 st := p.c.byIndex[idx] 363 st := p.c.byIndex[idx]
368 if !st.canSet { 364 if !st.canSet {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 switch val { 602 switch val {
607 case "on", "On", "true": 603 case "on", "On", "true":
608 return true, nil 604 return true, nil
609 case "off", "Off", "false": 605 case "off", "Off", "false":
610 return false, nil 606 return false, nil
611 } 607 }
612 return nil, fmt.Errorf("Toggle field has bad/missing default, go t %q", val) 608 return nil, fmt.Errorf("Toggle field has bad/missing default, go t %q", val)
613 } 609 }
614 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t , val) 610 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t , val)
615 } 611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698