OLD | NEW |
---|---|
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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 229 |
230 func newKeyObjErr(nk newKeyFunc, src interface{}) (Key, error) { | 230 func newKeyObjErr(nk newKeyFunc, src interface{}) (Key, error) { |
231 pls, name := mkPLSName(src) | 231 pls, name := mkPLSName(src) |
232 if key, _ := pls.GetMetaDefault("key", nil).(Key); key != nil { | 232 if key, _ := pls.GetMetaDefault("key", nil).(Key); key != nil { |
233 return key, nil | 233 return key, nil |
234 } | 234 } |
235 | 235 |
236 // get kind | 236 // get kind |
237 kind := pls.GetMetaDefault("kind", name).(string) | 237 kind := pls.GetMetaDefault("kind", name).(string) |
238 if kind == "" { | 238 if kind == "" { |
239 return nil, fmt.Errorf("unable to extract $kind from %v", src) | 239 return nil, fmt.Errorf("unable to extract $kind from %v", src) |
dnj (Google)
2015/08/15 02:32:32
(this error)
| |
240 } | 240 } |
241 | 241 |
242 // get id - allow both to be default for default keys | 242 // get id - allow both to be default for default keys |
243 sid := pls.GetMetaDefault("id", "").(string) | 243 sid := pls.GetMetaDefault("id", "").(string) |
244 iid := pls.GetMetaDefault("id", 0).(int64) | 244 iid := pls.GetMetaDefault("id", 0).(int64) |
245 | 245 |
246 // get parent | 246 // get parent |
247 par, _ := pls.GetMetaDefault("parent", nil).(Key) | 247 par, _ := pls.GetMetaDefault("parent", nil).(Key) |
248 | 248 |
249 return nk(kind, sid, iid, par), nil | 249 return nk(kind, sid, iid, par), nil |
(...skipping 10 matching lines...) Expand all Loading... | |
260 pls.SetMeta("kind", key.Kind()) | 260 pls.SetMeta("kind", key.Kind()) |
261 pls.SetMeta("parent", key.Parent()) | 261 pls.SetMeta("parent", key.Parent()) |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 func mkPLSName(o interface{}) (PropertyLoadSaver, string) { | 265 func mkPLSName(o interface{}) (PropertyLoadSaver, string) { |
266 if pls, ok := o.(*structPLS); ok { | 266 if pls, ok := o.(*structPLS); ok { |
267 return pls, pls.o.Type().Name() | 267 return pls, pls.o.Type().Name() |
268 } | 268 } |
269 if pls, ok := o.(PropertyLoadSaver); ok { | 269 if pls, ok := o.(PropertyLoadSaver); ok { |
270 » » return pls, "" | 270 » » v, _ := getPLSValue(o) |
271 » » return pls, v.Type().Name() | |
iannucci
2015/08/15 02:23:53
This looks really wrong to me. We already see if i
dnj (Google)
2015/08/15 02:32:32
The problem occurs when I implement a custom Prope
| |
271 } | 272 } |
272 pls := GetPLS(o) | 273 pls := GetPLS(o) |
273 name := pls.(*structPLS).o.Type().Name() | 274 name := pls.(*structPLS).o.Type().Name() |
274 return pls, name | 275 return pls, name |
275 } | 276 } |
OLD | NEW |