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

Unified Diff: service/datastore/serialize/serialize.go

Issue 1336443003: Implement projection queries correctly. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/reflect.go ('k') | service/datastore/serialize/serialize_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/serialize/serialize.go
diff --git a/service/datastore/serialize/serialize.go b/service/datastore/serialize/serialize.go
index 200cf24d2b9d271fb3df1ac2b05af8950a96d798..9b7d7c7100091267ee3660f7f48c9e152d78c47a 100644
--- a/service/datastore/serialize/serialize.go
+++ b/service/datastore/serialize/serialize.go
@@ -222,7 +222,14 @@ func WriteProperty(buf Buffer, context KeyContext, p ds.Property) (err error) {
}
panicIf(buf.WriteByte(typb))
switch p.Type() {
- case ds.PTNull, ds.PTBoolTrue, ds.PTBoolFalse:
+ case ds.PTNull:
+ case ds.PTBool:
+ b := p.Value().(bool)
+ if b {
+ err = buf.WriteByte(1)
+ } else {
+ err = buf.WriteByte(0)
+ }
case ds.PTInt:
_, err = cmpbin.WriteInt(buf, p.Value().(int64))
case ds.PTFloat:
@@ -230,11 +237,7 @@ func WriteProperty(buf Buffer, context KeyContext, p ds.Property) (err error) {
case ds.PTString:
_, err = cmpbin.WriteString(buf, p.Value().(string))
case ds.PTBytes:
- if p.IndexSetting() == ds.NoIndex {
- _, err = cmpbin.WriteBytes(buf, p.Value().([]byte))
- } else {
- _, err = cmpbin.WriteBytes(buf, p.Value().(ds.ByteString))
- }
+ _, err = cmpbin.WriteBytes(buf, p.Value().([]byte))
case ds.PTTime:
err = WriteTime(buf, p.Value().(time.Time))
case ds.PTGeoPoint:
@@ -252,20 +255,19 @@ func WriteProperty(buf Buffer, context KeyContext, p ds.Property) (err error) {
// effect if the decoded property has a Key value.
func ReadProperty(buf Buffer, context KeyContext, appid, namespace string) (p ds.Property, err error) {
val := interface{}(nil)
- typb, err := buf.ReadByte()
+ b, err := buf.ReadByte()
if err != nil {
return
}
is := ds.ShouldIndex
- if (typb & 0x80) == 0 {
+ if (b & 0x80) == 0 {
is = ds.NoIndex
}
- switch ds.PropertyType(typb & 0x7f) {
+ switch ds.PropertyType(b & 0x7f) {
case ds.PTNull:
- case ds.PTBoolTrue:
- val = true
- case ds.PTBoolFalse:
- val = false
+ case ds.PTBool:
+ b, err = buf.ReadByte()
+ val = (b != 0)
case ds.PTInt:
val, _, err = cmpbin.ReadInt(buf)
case ds.PTFloat:
@@ -273,15 +275,7 @@ func ReadProperty(buf Buffer, context KeyContext, appid, namespace string) (p ds
case ds.PTString:
val, _, err = cmpbin.ReadString(buf)
case ds.PTBytes:
- b := []byte(nil)
- if b, _, err = cmpbin.ReadBytes(buf); err != nil {
- break
- }
- if is == ds.NoIndex {
- val = b
- } else {
- val = ds.ByteString(b)
- }
+ val, _, err = cmpbin.ReadBytes(buf)
case ds.PTTime:
val, err = ReadTime(buf)
case ds.PTGeoPoint:
@@ -295,7 +289,7 @@ func ReadProperty(buf Buffer, context KeyContext, appid, namespace string) (p ds
}
val = blobstore.Key(s)
default:
- err = fmt.Errorf("read: unknown type! %v", typb)
+ err = fmt.Errorf("read: unknown type! %v", b)
}
if err == nil {
err = p.SetValue(val, is)
« no previous file with comments | « service/datastore/reflect.go ('k') | service/datastore/serialize/serialize_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698