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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 // IneqFilterProp returns the inequality filter property name, if one is used | 147 // IneqFilterProp returns the inequality filter property name, if one is used |
148 // for this filter. An empty return value means that this query does not | 148 // for this filter. An empty return value means that this query does not |
149 // contain any inequality filters. | 149 // contain any inequality filters. |
150 func (q *FinalizedQuery) IneqFilterProp() string { | 150 func (q *FinalizedQuery) IneqFilterProp() string { |
151 return q.ineqFiltProp | 151 return q.ineqFiltProp |
152 } | 152 } |
153 | 153 |
154 // IneqFilterLow returns the field name, operator and value for the low-side | 154 // IneqFilterLow returns the field name, operator and value for the low-side |
155 // inequality filter. If the returned field name is "", it means that there's | 155 // inequality filter. If the returned field name is "", it means that there's |
156 // now lower inequality bound on this query. | 156 // no lower inequality bound on this query. |
157 // | 157 // |
158 // If field is non-empty, op may have the values ">" or ">=". | 158 // If field is non-empty, op may have the values ">" or ">=". |
159 func (q *FinalizedQuery) IneqFilterLow() (field, op string, val Property) { | 159 func (q *FinalizedQuery) IneqFilterLow() (field, op string, val Property) { |
160 if q.ineqFiltLowSet { | 160 if q.ineqFiltLowSet { |
161 field = q.ineqFiltProp | 161 field = q.ineqFiltProp |
162 val = q.ineqFiltLow | 162 val = q.ineqFiltLow |
163 op = ">" | 163 op = ">" |
164 if q.ineqFiltLowIncl { | 164 if q.ineqFiltLowIncl { |
165 op = ">=" | 165 op = ">=" |
166 } | 166 } |
167 } | 167 } |
168 return | 168 return |
169 } | 169 } |
170 | 170 |
171 // IneqFilterHigh returns the field name, operator and value for the high-side | 171 // IneqFilterHigh returns the field name, operator and value for the high-side |
172 // inequality filter. If the returned field name is "", it means that there's | 172 // inequality filter. If the returned field name is "", it means that there's |
173 // now upper inequality bound on this query. | 173 // no upper inequality bound on this query. |
174 // | 174 // |
175 // If field is non-empty, op may have the values "<" or "<=". | 175 // If field is non-empty, op may have the values "<" or "<=". |
176 func (q *FinalizedQuery) IneqFilterHigh() (field, op string, val Property) { | 176 func (q *FinalizedQuery) IneqFilterHigh() (field, op string, val Property) { |
177 if q.ineqFiltHighSet { | 177 if q.ineqFiltHighSet { |
178 field = q.ineqFiltProp | 178 field = q.ineqFiltProp |
179 val = q.ineqFiltHigh | 179 val = q.ineqFiltHigh |
180 op = "<" | 180 op = "<" |
181 if q.ineqFiltHighIncl { | 181 if q.ineqFiltHighIncl { |
182 op = "<=" | 182 op = "<=" |
183 } | 183 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 if q.ineqFiltProp == "__key__" { | 330 if q.ineqFiltProp == "__key__" { |
331 if q.ineqFiltLowSet && !q.ineqFiltLow.Value().(*Key).Valid(false
, aid, ns) { | 331 if q.ineqFiltLowSet && !q.ineqFiltLow.Value().(*Key).Valid(false
, aid, ns) { |
332 return ErrInvalidKey | 332 return ErrInvalidKey |
333 } | 333 } |
334 if q.ineqFiltHighSet && !q.ineqFiltHigh.Value().(*Key).Valid(fal
se, aid, ns) { | 334 if q.ineqFiltHighSet && !q.ineqFiltHigh.Value().(*Key).Valid(fal
se, aid, ns) { |
335 return ErrInvalidKey | 335 return ErrInvalidKey |
336 } | 336 } |
337 } | 337 } |
338 return nil | 338 return nil |
339 } | 339 } |
OLD | NEW |