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

Unified Diff: service/datastore/pls_impl.go

Issue 1259593005: Add 'user friendly' datastore API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: more docs 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/pls.go ('k') | service/datastore/properties.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/pls_impl.go
diff --git a/service/datastore/pls_impl.go b/service/datastore/pls_impl.go
index f2d3e43114e2c86bd645a02b55014f9a41084525..9a369123c59cf58b2431ab169fa568f2638bcfea 100644
--- a/service/datastore/pls_impl.go
+++ b/service/datastore/pls_impl.go
@@ -359,7 +359,12 @@ func (p *structPLS) SetMeta(key string, val interface{}) (err error) {
val = Off
}
}
- p.o.Field(idx).Set(reflect.ValueOf(val))
+ f := p.o.Field(idx)
+ if val == nil {
+ f.Set(reflect.Zero(f.Type()))
+ } else {
+ f.Set(reflect.ValueOf(val))
+ }
return nil
}
@@ -369,7 +374,7 @@ var (
// The RWMutex is chosen intentionally, as the majority of access to the
// structCodecs map will be in parallel and will be to read an existing codec.
// There's no reason to serialize goroutines on every
- // gae.datastore.{Get,Put}{,Multi} call.
+ // gae.Interface.{Get,Put}{,Multi} call.
structCodecsMutex sync.RWMutex
structCodecs = map[reflect.Type]*structCodec{}
)
@@ -563,6 +568,11 @@ func convertMeta(val string, t reflect.Type) (interface{}, error) {
switch t {
case typeOfString:
return val, nil
+ case typeOfKey:
+ if val != "" {
+ return nil, fmt.Errorf("key field is not allowed to have a default: %q", val)
+ }
+ return nil, nil
case typeOfInt64:
if val == "" {
return int64(0), nil
« no previous file with comments | « service/datastore/pls.go ('k') | service/datastore/properties.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698