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

Unified Diff: service/datastore/finalized_query.go

Issue 1745703002: Auto-project on distinct inequality fields. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 10 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: service/datastore/finalized_query.go
diff --git a/service/datastore/finalized_query.go b/service/datastore/finalized_query.go
index 8a6d75725dc054ef419ee23b5c0f38bd01bcf762..393d06654838df95f7ff7247b284582906b7d96c 100644
--- a/service/datastore/finalized_query.go
+++ b/service/datastore/finalized_query.go
@@ -65,11 +65,23 @@ func (q *FinalizedQuery) EventuallyConsistent() bool {
// Project is the list of fields that this query projects on, or empty if this
// is not a projection query.
func (q *FinalizedQuery) Project() []string {
- if len(q.project) == 0 {
+ // For distinct queries with an inequality filter, one must first project the
+ // inequality field.
+ size := len(q.project)
+ ineqDistinctProject := ""
+ if q.distinct && q.ineqFiltProp != "" {
+ ineqDistinctProject = q.ineqFiltProp
+ size++
+ }
+
+ if size == 0 {
return nil
}
- ret := make([]string, len(q.project))
- copy(ret, q.project)
+ ret := make([]string, 0, size)
+ if ineqDistinctProject != "" {
+ ret = append(ret, ineqDistinctProject)
+ }
+ ret = append(ret, q.project...)
iannucci 2016/02/27 00:58:51 ditch this whole thing
return ret
}

Powered by Google App Engine
This is Rietveld 408576698