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

Unified Diff: impl/memory/datastore_query_execution_test.go

Issue 1336443003: Implement projection queries correctly. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years, 3 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_execution_test.go
diff --git a/impl/memory/datastore_query_execution_test.go b/impl/memory/datastore_query_execution_test.go
index 01e779d2335ead31c50a4d907bb22234d311ae86..4d01684a29f13085b0d75d8e47aa1a28e6dac850 100644
--- a/impl/memory/datastore_query_execution_test.go
+++ b/impl/memory/datastore_query_execution_test.go
@@ -7,6 +7,7 @@ package memory
import (
"fmt"
"testing"
+ "time"
ds "github.com/luci/gae/service/datastore"
"github.com/luci/gae/service/info"
@@ -45,14 +46,17 @@ var stage1Data = []ds.PropertyMap{
),
pmap("$key", key("Kind", 2), NEXT,
"Val", 6, 8, 7, NEXT,
+ "When", 27, NEXT,
"Extra", "zebra",
),
pmap("$key", key("Kind", 3), NEXT,
"Val", 1, 2, 2, 100, NEXT,
+ "When", 996688461000000, NEXT,
"Extra", "waffle",
),
pmap("$key", key("Kind", 6), NEXT,
"Val", 5, NEXT,
+ "When", time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC), NEXT,
"Extra", "waffle",
),
pmap("$key", key("Child", "seven", key("Kind", 3)), NEXT,
@@ -224,6 +228,25 @@ var queryExecutionTests = []qExTest{
pmap("$key", key("Kind", 2, key("Kind", 3)), NEXT,
"Val", 3),
}},
+
+ // Projecting a complex type (time), gets the index type (int64)
+ // instead. Additionally, mixed-types within the same index type are
+ // smooshed together in the result.
+ {q: nq("Kind").Project("When"), get: []ds.PropertyMap{
+ pmap("$key", key("Kind", 2), NEXT,
+ "When", 27),
+ pmap("$key", key("Kind", 6), NEXT,
+ "When", 946688461000000),
+ pmap("$key", key("Kind", 3), NEXT,
+ "When", 996688461000000),
+ }},
+
+ // Original (complex) types are retained when getting the full value.
+ {q: nq("Kind").Order("When"), get: []ds.PropertyMap{
+ stage1Data[1],
+ stage1Data[3],
+ stage1Data[2],
+ }},
},
extraFns: []func(context.Context){

Powered by Google App Engine
This is Rietveld 408576698