| Index: impl/memory/raw_datastore_query.go
|
| diff --git a/memory/raw_datastore_query.go b/impl/memory/raw_datastore_query.go
|
| similarity index 91%
|
| rename from memory/raw_datastore_query.go
|
| rename to impl/memory/raw_datastore_query.go
|
| index 68172a42be2406c28ad01e670a16658a5335720c..1ee48f36d8de0c8f85cd3731c0798233dd00903e 100644
|
| --- a/memory/raw_datastore_query.go
|
| +++ b/impl/memory/raw_datastore_query.go
|
| @@ -11,8 +11,7 @@ import (
|
| "math"
|
| "strings"
|
|
|
| - "github.com/luci/gae"
|
| - "github.com/luci/gae/helper"
|
| + rds "github.com/luci/gae/service/rawdatastore"
|
| "github.com/luci/gkvlite"
|
| "github.com/luci/luci-go/common/cmpbin"
|
| )
|
| @@ -220,7 +219,7 @@ type queryImpl struct {
|
| ns string
|
|
|
| kind string
|
| - ancestor gae.DSKey
|
| + ancestor rds.Key
|
| filter []queryFilter
|
| order []queryOrder
|
| project []string
|
| @@ -237,22 +236,22 @@ type queryImpl struct {
|
| err error
|
| }
|
|
|
| -var _ gae.DSQuery = (*queryImpl)(nil)
|
| +var _ rds.Query = (*queryImpl)(nil)
|
|
|
| type queryIterImpl struct {
|
| idx *queryImpl
|
| }
|
|
|
| -var _ gae.RDSIterator = (*queryIterImpl)(nil)
|
| +var _ rds.Iterator = (*queryIterImpl)(nil)
|
|
|
| -func (q *queryIterImpl) Cursor() (gae.DSCursor, error) {
|
| +func (q *queryIterImpl) Cursor() (rds.Cursor, error) {
|
| if q.idx.err != nil {
|
| return nil, q.idx.err
|
| }
|
| return nil, nil
|
| }
|
|
|
| -func (q *queryIterImpl) Next(dst gae.DSPropertyLoadSaver) (gae.DSKey, error) {
|
| +func (q *queryIterImpl) Next(dst rds.PropertyLoadSaver) (rds.Key, error) {
|
| if q.idx.err != nil {
|
| return nil, q.idx.err
|
| }
|
| @@ -387,17 +386,17 @@ func (q *queryImpl) checkCorrectness(ns string, isTxn bool) (ret *queryImpl) {
|
| ineqPropName := ""
|
| for _, f := range ret.filter {
|
| if f.field == "__key__" {
|
| - k, ok := f.value.(gae.DSKey)
|
| + k, ok := f.value.(rds.Key)
|
| if !ok {
|
| ret.err = errors.New(
|
| "gae/memory: __key__ filter value must be a Key")
|
| return
|
| }
|
| - if !helper.DSKeyValid(k, ret.ns, false) {
|
| + if !rds.KeyValid(k, ret.ns, false) {
|
| // See the comment in queryImpl.Ancestor; basically this check
|
| // never happens in the real env because the SDK silently swallows
|
| // this condition :/
|
| - ret.err = gae.ErrDSInvalidKey
|
| + ret.err = rds.ErrInvalidKey
|
| return
|
| }
|
| // __key__ filter app is X but query app is X
|
| @@ -475,30 +474,30 @@ func (q *queryImpl) clone() *queryImpl {
|
| return &ret
|
| }
|
|
|
| -func (q *queryImpl) Ancestor(k gae.DSKey) gae.DSQuery {
|
| +func (q *queryImpl) Ancestor(k rds.Key) rds.Query {
|
| q = q.clone()
|
| q.ancestor = k
|
| if k == nil {
|
| // SDK has an explicit nil-check
|
| q.err = errors.New("datastore: nil query ancestor")
|
| - } else if !helper.DSKeyValid(k, q.ns, false) {
|
| + } else if !rds.KeyValid(k, q.ns, false) {
|
| // 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,
|
| // you'll never actually hear about it. Instead of doing that insanity, we
|
| // just swap to an error here.
|
| - q.err = gae.ErrDSInvalidKey
|
| + q.err = rds.ErrInvalidKey
|
| }
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Distinct() gae.DSQuery {
|
| +func (q *queryImpl) Distinct() rds.Query {
|
| q = q.clone()
|
| q.distinct = true
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Filter(fStr string, val interface{}) gae.DSQuery {
|
| +func (q *queryImpl) Filter(fStr string, val interface{}) rds.Query {
|
| q = q.clone()
|
| f, err := parseFilter(fStr, val)
|
| if err != nil {
|
| @@ -509,7 +508,7 @@ func (q *queryImpl) Filter(fStr string, val interface{}) gae.DSQuery {
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Order(field string) gae.DSQuery {
|
| +func (q *queryImpl) Order(field string) rds.Query {
|
| q = q.clone()
|
| field = strings.TrimSpace(field)
|
| o := queryOrder{field, qASC}
|
| @@ -528,19 +527,19 @@ func (q *queryImpl) Order(field string) gae.DSQuery {
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Project(fieldName ...string) gae.DSQuery {
|
| +func (q *queryImpl) Project(fieldName ...string) rds.Query {
|
| q = q.clone()
|
| q.project = append(q.project, fieldName...)
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) KeysOnly() gae.DSQuery {
|
| +func (q *queryImpl) KeysOnly() rds.Query {
|
| q = q.clone()
|
| q.keysOnly = true
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Limit(limit int) gae.DSQuery {
|
| +func (q *queryImpl) Limit(limit int) rds.Query {
|
| q = q.clone()
|
| if limit < math.MinInt32 || limit > math.MaxInt32 {
|
| q.err = errors.New("datastore: query limit overflow")
|
| @@ -550,7 +549,7 @@ func (q *queryImpl) Limit(limit int) gae.DSQuery {
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Offset(offset int) gae.DSQuery {
|
| +func (q *queryImpl) Offset(offset int) rds.Query {
|
| q = q.clone()
|
| if offset < 0 {
|
| q.err = errors.New("datastore: negative query offset")
|
| @@ -564,7 +563,7 @@ func (q *queryImpl) Offset(offset int) gae.DSQuery {
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) Start(c gae.DSCursor) gae.DSQuery {
|
| +func (q *queryImpl) Start(c rds.Cursor) rds.Query {
|
| q = q.clone()
|
| curs := c.(queryCursor)
|
| if !curs.Valid() {
|
| @@ -575,7 +574,7 @@ func (q *queryImpl) Start(c gae.DSCursor) gae.DSQuery {
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) End(c gae.DSCursor) gae.DSQuery {
|
| +func (q *queryImpl) End(c rds.Cursor) rds.Query {
|
| q = q.clone()
|
| curs := c.(queryCursor)
|
| if !curs.Valid() {
|
| @@ -586,7 +585,7 @@ func (q *queryImpl) End(c gae.DSCursor) gae.DSQuery {
|
| return q
|
| }
|
|
|
| -func (q *queryImpl) EventualConsistency() gae.DSQuery {
|
| +func (q *queryImpl) EventualConsistency() rds.Query {
|
| q = q.clone()
|
| q.eventualConsistency = true
|
| return q
|
|
|