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

Side by Side Diff: service/datastore/pls_impl.go

Issue 1270113002: Re-add metadata passthrough on Get operations (Closed) Base URL: https://github.com/luci/gae.git@fix_other_interfaces
Patch Set: safer, add tests 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 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if !reflect.DeepEqual(reflect.Zero(f.Type()).Interface(), f.Inte rface()) { 333 if !reflect.DeepEqual(reflect.Zero(f.Type()).Interface(), f.Inte rface()) {
334 val = f.Interface() 334 val = f.Interface()
335 if bf, ok := val.(Toggle); ok { 335 if bf, ok := val.(Toggle); ok {
336 val = bf == On // true if On, otherwise false 336 val = bf == On // true if On, otherwise false
337 } 337 }
338 } 338 }
339 } 339 }
340 return val, nil 340 return val, nil
341 } 341 }
342 342
343 func (p *structPLS) GetMetaDefault(key string, def interface{}) interface{} {
344 return GetMetaDefaultImpl(p.GetMeta, key, def)
345 }
346
343 func (p *structPLS) SetMeta(key string, val interface{}) (err error) { 347 func (p *structPLS) SetMeta(key string, val interface{}) (err error) {
344 if err = p.Problem(); err != nil { 348 if err = p.Problem(); err != nil {
345 return 349 return
346 } 350 }
347 idx, ok := p.c.byMeta[key] 351 idx, ok := p.c.byMeta[key]
348 if !ok { 352 if !ok {
349 return ErrMetaFieldUnset 353 return ErrMetaFieldUnset
350 } 354 }
351 if !p.c.byIndex[idx].canSet { 355 if !p.c.byIndex[idx].canSet {
352 return fmt.Errorf("gae/helper: cannot set meta %q: unexported fi eld", key) 356 return fmt.Errorf("gae/helper: cannot set meta %q: unexported fi eld", key)
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 switch val { 586 switch val {
583 case "on", "On", "true": 587 case "on", "On", "true":
584 return true, nil 588 return true, nil
585 case "off", "Off", "false": 589 case "off", "Off", "false":
586 return false, nil 590 return false, nil
587 } 591 }
588 return nil, fmt.Errorf("Toggle field has bad/missing default, go t %q", val) 592 return nil, fmt.Errorf("Toggle field has bad/missing default, go t %q", val)
589 } 593 }
590 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t , val) 594 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t , val)
591 } 595 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698