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: 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
Index: impl/memory/datastore_query.go
diff --git a/impl/memory/datastore_query.go b/impl/memory/datastore_query.go
index e4f00716a65a413d2702baf3f1d602877f05d71d..ab34629e14160d6c8934347b64c5c56aa23a225a 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"
)
const MaxQueryComponents = 100
@@ -246,7 +246,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,
@@ -297,13 +297,12 @@ 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
}
}
- buf := &bytes.Buffer{}
- p.Write(buf, ds.WithoutContext)
+ binVal = string(serialize.ToBytes(p))
if prop == "__key__" {
if op == qEqual {
@@ -331,7 +330,6 @@ func (q *queryImpl) Filter(fStr string, val interface{}) ds.Query {
"cannot project on field which is used in an equality filter: %q",
prop)
}
- binVal = buf.String()
return
},
func(q *queryImpl) {

Powered by Google App Engine
This is Rietveld 408576698