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

Unified Diff: service/datastore/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: Group similar logics. 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
« no previous file with comments | « impl/prod/everything_test.go ('k') | service/datastore/query_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/query.go
diff --git a/service/datastore/query.go b/service/datastore/query.go
index fc30f5f686808fc6f697a000c6be3bdf94e0cf65..2e60b90cda8e90ce8fe0b95f88a21635cd6d3dcd 100644
--- a/service/datastore/query.go
+++ b/service/datastore/query.go
@@ -573,6 +573,12 @@ func (q *Query) Finalize() (*FinalizedQuery, error) {
if q.project != nil {
ret.project = q.project.ToSlice()
ret.distinct = q.distinct && q.project.Len() > 0
+
+ // If we're DISTINCT && have an inequality filter, we must project that
+ // inequality property as well.
+ if ret.distinct && ret.ineqFiltProp != "" && !q.project.Has(ret.ineqFiltProp) {
+ ret.project = append([]string{ret.ineqFiltProp}, ret.project...)
+ }
}
seenOrders := stringset.New(len(q.order))
« no previous file with comments | « impl/prod/everything_test.go ('k') | service/datastore/query_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698