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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « impl/prod/everything_test.go ('k') | service/datastore/query_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package datastore 5 package datastore
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "fmt" 9 "fmt"
10 "sort" 10 "sort"
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 ineqFiltLowIncl: q.ineqFiltLowIncl, 566 ineqFiltLowIncl: q.ineqFiltLowIncl,
567 ineqFiltLowSet: q.ineqFiltLowSet, 567 ineqFiltLowSet: q.ineqFiltLowSet,
568 ineqFiltHigh: q.ineqFiltHigh, 568 ineqFiltHigh: q.ineqFiltHigh,
569 ineqFiltHighIncl: q.ineqFiltHighIncl, 569 ineqFiltHighIncl: q.ineqFiltHighIncl,
570 ineqFiltHighSet: q.ineqFiltHighSet, 570 ineqFiltHighSet: q.ineqFiltHighSet,
571 } 571 }
572 572
573 if q.project != nil { 573 if q.project != nil {
574 ret.project = q.project.ToSlice() 574 ret.project = q.project.ToSlice()
575 ret.distinct = q.distinct && q.project.Len() > 0 575 ret.distinct = q.distinct && q.project.Len() > 0
576
577 // If we're DISTINCT && have an inequality filter, we must proje ct that
578 // inequality property as well.
579 if ret.distinct && ret.ineqFiltProp != "" && !q.project.Has(ret. ineqFiltProp) {
580 ret.project = append([]string{ret.ineqFiltProp}, ret.pro ject...)
581 }
576 } 582 }
577 583
578 seenOrders := stringset.New(len(q.order)) 584 seenOrders := stringset.New(len(q.order))
579 585
580 // if len(q.order) > 0, we already enforce that the first order 586 // if len(q.order) > 0, we already enforce that the first order
581 // is the same as the inequality above. Otherwise we need to add it. 587 // is the same as the inequality above. Otherwise we need to add it.
582 if len(q.order) == 0 && q.ineqFiltProp != "" { 588 if len(q.order) == 0 && q.ineqFiltProp != "" {
583 ret.orders = []IndexColumn{{Property: q.ineqFiltProp}} 589 ret.orders = []IndexColumn{{Property: q.ineqFiltProp}}
584 seenOrders.Add(q.ineqFiltProp) 590 seenOrders.Add(q.ineqFiltProp)
585 } 591 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 if q.keysOnly { 733 if q.keysOnly {
728 p("KeysOnly") 734 p("KeysOnly")
729 } 735 }
730 736
731 if _, err := ret.WriteRune(')'); err != nil { 737 if _, err := ret.WriteRune(')'); err != nil {
732 panic(err) 738 panic(err)
733 } 739 }
734 740
735 return ret.String() 741 return ret.String()
736 } 742 }
OLDNEW
« 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