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() |