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 |
} |