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

Unified Diff: impl/memory/datastore_query.go

Issue 1292913002: Split off serialization and key functions to their own packages. (Closed) Base URL: https://github.com/luci/gae.git@make_queries_better
Patch Set: rebase 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 | « impl/memory/datastore_index.go ('k') | impl/memory/datastore_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_query.go
diff --git a/impl/memory/datastore_query.go b/impl/memory/datastore_query.go
index e263bec9a151dde14901b2e7b1010129722f9b1a..a9b22f2efb9c5abb05684e8fe22076872ce66e98 100644
--- a/impl/memory/datastore_query.go
+++ b/impl/memory/datastore_query.go
@@ -5,13 +5,13 @@
package memory
import (
- "bytes"
"errors"
"fmt"
"math"
"strings"
ds "github.com/luci/gae/service/datastore"
+ "github.com/luci/gae/service/datastore/serialize"
)
// MaxQueryComponents was lifted from a hard-coded constant in dev_appserver.
@@ -250,7 +250,7 @@ func (q *queryImpl) Ancestor(k ds.Key) ds.Query {
// SDK has an explicit nil-check
return errors.New("datastore: nil query ancestor")
}
- if !ds.KeyValid(k, false, globalAppID, q.ns) {
+ if !k.Valid(false, globalAppID, q.ns) {
// technically the SDK implementation does a Weird Thing (tm) if both the
// stringID and intID are set on a key; it only serializes the stringID in
// the proto. This means that if you set the Ancestor to an invalid key,
@@ -302,7 +302,7 @@ func (q *queryImpl) Filter(fStr string, val interface{}) ds.Query {
}
if p.Type() == ds.PTKey {
- if !ds.KeyValid(p.Value().(ds.Key), false, globalAppID, q.ns) {
+ if !p.Value().(ds.Key).Valid(false, globalAppID, q.ns) {
return ds.ErrInvalidKey
}
}
@@ -333,11 +333,8 @@ func (q *queryImpl) Filter(fStr string, val interface{}) ds.Query {
"cannot project on field which is used in an equality filter: %q",
prop)
}
-
- buf := &bytes.Buffer{}
- p.Write(buf, ds.WithoutContext)
- binVal = buf.String()
- return nil
+ binVal = string(serialize.ToBytes(p))
+ return err
},
func(q *queryImpl) {
if op == qEqual {
« no previous file with comments | « impl/memory/datastore_index.go ('k') | impl/memory/datastore_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698