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

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

Issue 1358063003: Add Kind/StringID/IntID back to Key. (Closed) Base URL: https://github.com/luci/gae.git@add_allocate_ids
Patch Set: Created 5 years, 3 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
« service/datastore/key.go ('K') | « service/datastore/key.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 package datastore 5 package datastore
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "reflect" 9 "reflect"
10 10
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 // get parent 269 // get parent
270 par, _ := pls.GetMetaDefault("parent", nil).(*Key) 270 par, _ := pls.GetMetaDefault("parent", nil).(*Key)
271 271
272 return NewKey(aid, ns, kind, sid, iid, par), nil 272 return NewKey(aid, ns, kind, sid, iid, par), nil
273 } 273 }
274 274
275 func setKey(src interface{}, key *Key) { 275 func setKey(src interface{}, key *Key) {
276 pls := mkPLS(src) 276 pls := mkPLS(src)
277 if pls.SetMeta("key", key) == ErrMetaFieldUnset { 277 if pls.SetMeta("key", key) == ErrMetaFieldUnset {
278 » » lst := key.Last() 278 » » lst := key.LastTok()
279 if lst.StringID != "" { 279 if lst.StringID != "" {
280 _ = pls.SetMeta("id", lst.StringID) 280 _ = pls.SetMeta("id", lst.StringID)
281 } else { 281 } else {
282 _ = pls.SetMeta("id", lst.IntID) 282 _ = pls.SetMeta("id", lst.IntID)
283 } 283 }
284 _ = pls.SetMeta("kind", lst.Kind) 284 _ = pls.SetMeta("kind", lst.Kind)
285 _ = pls.SetMeta("parent", key.Parent()) 285 _ = pls.SetMeta("parent", key.Parent())
286 } 286 }
287 } 287 }
288 288
289 func mkPLS(o interface{}) PropertyLoadSaver { 289 func mkPLS(o interface{}) PropertyLoadSaver {
290 if pls, ok := o.(PropertyLoadSaver); ok { 290 if pls, ok := o.(PropertyLoadSaver); ok {
291 return pls 291 return pls
292 } 292 }
293 return GetPLS(o) 293 return GetPLS(o)
294 } 294 }
OLDNEW
« service/datastore/key.go ('K') | « service/datastore/key.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698