OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |