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

Unified Diff: impl/memory/datastore_test.go

Issue 2517833002: Fix #66. (Closed)
Patch Set: Created 4 years, 1 month 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_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_test.go
diff --git a/impl/memory/datastore_test.go b/impl/memory/datastore_test.go
index c9580f0f7f1af8cad4585884b1ab52948557a426..045c8c37d1336f9e97b7972574585eabb1d2de1a 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -731,6 +731,32 @@ func TestDefaultTimeField(t *testing.T) {
})
}
+// High level test for ancestor queries where the parent and child have
+// identical fields. There was a bug where it would accidentally load the parent
+// entity when attempt to query for the child.
+func TestAncestorChildFieldQuery(t *testing.T) {
dnj 2016/11/20 16:44:25 Can this test be folded up into one of the "datast
+ ctx := Use(context.Background())
+ testable := ds.GetTestable(ctx)
+ testable.Consistent(true)
+ testable.AutoIndex(true)
+
+ type Parent struct {
+ _ int64 `gae:"$id,1"`
+ Created time.Time
+ }
+ p := Parent{}
+ if err := ds.Put(ctx, &p); err != nil {
+ t.Fatal(err)
+ }
+ // If you comment out the .Order part below, the test succeeds
dnj 2016/11/20 16:44:25 This comment can be removed.
+ q := ds.NewQuery("notParent").Ancestor(ds.KeyForObj(ctx, &p)).Order("-Created")
+ if val, err := ds.Count(ctx, q); err != nil {
+ t.Fatal(err)
+ } else if val != 0 {
+ t.Fatalf("val: %d != 0", val)
+ }
+}
+
func TestNewDatastore(t *testing.T) {
t.Parallel()
« no previous file with comments | « impl/memory/datastore_index_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698