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

Unified Diff: impl/memory/datastore.go

Issue 1286943002: impl/memory: Make queries self-validate (Closed) Base URL: https://github.com/luci/gae.git@add_datastore_testable
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 | « no previous file | impl/memory/datastore_index.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore.go
diff --git a/impl/memory/datastore.go b/impl/memory/datastore.go
index 53e72be7ec9a424817465115a894ea1cfd845554..8af720030bf7a489c6b3915b90210dc13691636d 100644
--- a/impl/memory/datastore.go
+++ b/impl/memory/datastore.go
@@ -68,6 +68,11 @@ func (d *dsImpl) NewQuery(kind string) ds.Query {
}
func (d *dsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
+ rq := q.(*queryImpl)
+ done, err := rq.valid(d.ns, true)
+ if done || err != nil {
+ return err // will be nil if done
+ }
return nil
}
@@ -137,11 +142,12 @@ func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error {
func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
rq := q.(*queryImpl)
- if rq.ancestor == nil {
- return errors.New("gae/impl/memory: queries in transactions only support ancestor queries")
+ done, err := rq.valid(d.ns, true)
+ if done || err != nil {
+ return err // will be nil if done
}
if rq.eventualConsistency {
- rq = rq.clone()
+ rq = rq.checkMutateClone(nil, nil)
rq.eventualConsistency = false
}
// TODO(riannucci): use head instead of snap for indexes
« no previous file with comments | « no previous file | impl/memory/datastore_index.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698