forked from tetrafolium/luci-gae
/
query.go
782 lines (707 loc) · 20 KB
/
query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
// Copyright 2015 The LUCI Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package datastore
import (
"bytes"
"fmt"
"sort"
"strings"
"sync"
"go.chromium.org/luci/common/data/stringset"
"go.chromium.org/luci/common/errors"
)
var (
// ErrMultipleInequalityFilter is returned from Query.Finalize if you build a
// query which has inequality filters on multiple fields.
ErrMultipleInequalityFilter = errors.New(
"inequality filters on multiple properties in the same Query is not allowed")
// ErrNullQuery is returned from Query.Finalize if you build a query for which
// there cannot possibly be any results.
ErrNullQuery = errors.New(
"the query is overconstrained and can never have results")
)
// Query is a builder-object for building a datastore query. It may represent
// an invalid query, but the error will only be observable when you call
// Finalize.
//
// A Query is, for the most part, not goroutine-safe. However, it is
type Query struct {
queryFields
// These are set by Finalize as a way to cache the 1-1 correspondence of
// a Query to its FinalizedQuery form. err may also be set by intermediate
// Query functions if there's a problem before finalization.
//
// Query implements lazy finalization, meaning that it will happen at most
// once. This means that the finalization state and cached finalization must
// be locked around.
finalizeOnce sync.Once
finalized *FinalizedQuery
finalizeErr error
}
// queryFields are the Query's read-only fields.
type queryFields struct {
kind string
eventualConsistency bool
keysOnly bool
distinct bool
limit *int32
offset *int32
order []IndexColumn
project stringset.Set
eqFilts map[string]PropertySlice
ineqFiltProp string
ineqFiltLow Property
ineqFiltLowIncl bool
ineqFiltLowSet bool
ineqFiltHigh Property
ineqFiltHighIncl bool
ineqFiltHighSet bool
start Cursor
end Cursor
err error
}
// NewQuery returns a new Query for the given kind. If kind may be empty to
// begin a kindless query.
func NewQuery(kind string) *Query {
return &Query{
queryFields: queryFields{
kind: kind,
},
}
}
func (q *Query) mod(cb func(*Query)) *Query {
if q.err != nil {
return q
}
ret := Query{
queryFields: q.queryFields,
}
if len(q.order) > 0 {
ret.order = make([]IndexColumn, len(q.order))
copy(ret.order, q.order)
}
if q.project != nil {
ret.project = q.project.Dup()
}
if len(q.eqFilts) > 0 {
ret.eqFilts = make(map[string]PropertySlice, len(q.eqFilts))
for k, v := range q.eqFilts {
newV := make(PropertySlice, len(v))
copy(newV, v)
ret.eqFilts[k] = newV
}
}
cb(&ret)
return &ret
}
// Kind alters the kind of this query.
func (q *Query) Kind(kind string) *Query {
return q.mod(func(q *Query) {
q.kind = kind
})
}
// Ancestor sets the ancestor filter for this query.
//
// If ancestor is nil, then this removes the Ancestor restriction from the
// query.
func (q *Query) Ancestor(ancestor *Key) *Query {
return q.mod(func(q *Query) {
if q.eqFilts == nil {
q.eqFilts = map[string]PropertySlice{}
}
if ancestor == nil {
delete(q.eqFilts, "__ancestor__")
if len(q.eqFilts) == 0 {
q.eqFilts = nil
}
} else {
q.eqFilts["__ancestor__"] = PropertySlice{MkProperty(ancestor)}
}
})
}
// EventualConsistency changes the EventualConsistency setting for this query.
//
// It only has an effect on Ancestor queries and is otherwise ignored.
func (q *Query) EventualConsistency(on bool) *Query {
return q.mod(func(q *Query) {
q.eventualConsistency = on
})
}
// Limit sets the limit (max items to return) for this query. If limit < 0, this
// removes the limit from the query entirely.
func (q *Query) Limit(limit int32) *Query {
return q.mod(func(q *Query) {
if limit < 0 {
q.limit = nil
} else {
q.limit = &limit
}
})
}
// Offset sets the offset (number of items to skip) for this query. If
// offset < 0, this removes the offset from the query entirely.
func (q *Query) Offset(offset int32) *Query {
return q.mod(func(q *Query) {
if offset < 0 {
q.offset = nil
} else {
q.offset = &offset
}
})
}
// KeysOnly makes this into a query which only returns keys (but doesn't fetch
// values). It's incompatible with projection queries.
func (q *Query) KeysOnly(on bool) *Query {
return q.mod(func(q *Query) {
q.keysOnly = on
})
}
// Order sets one or more orders for this query.
func (q *Query) Order(fieldNames ...string) *Query {
if len(fieldNames) == 0 {
return q
}
return q.mod(func(q *Query) {
for _, fn := range fieldNames {
ic, err := ParseIndexColumn(fn)
if err != nil {
q.err = err
return
}
if q.reserved(ic.Property) {
return
}
q.order = append(q.order, ic)
}
})
}
// ClearOrder removes all orders from this Query.
func (q *Query) ClearOrder() *Query {
return q.mod(func(q *Query) {
q.order = nil
})
}
// Project lists one or more field names to project.
func (q *Query) Project(fieldNames ...string) *Query {
if len(fieldNames) == 0 {
return q
}
return q.mod(func(q *Query) {
for _, f := range fieldNames {
if q.reserved(f) {
return
}
if f == "__key__" {
q.err = fmt.Errorf("cannot project on %q", f)
return
}
if q.project == nil {
q.project = stringset.New(1)
}
q.project.Add(f)
}
})
}
// Distinct makes a projection query only return distinct values. This has
// no effect on non-projection queries.
func (q *Query) Distinct(on bool) *Query {
return q.mod(func(q *Query) {
q.distinct = on
})
}
// ClearProject removes all projected fields from this Query.
func (q *Query) ClearProject() *Query {
return q.mod(func(q *Query) {
q.project = nil
})
}
// Start sets a starting cursor. The cursor is implementation-defined by the
// particular 'impl' you have installed.
func (q *Query) Start(c Cursor) *Query {
return q.mod(func(q *Query) {
q.start = c
})
}
// End sets the ending cursor. The cursor is implementation-defined by the
// particular 'impl' you have installed.
func (q *Query) End(c Cursor) *Query {
return q.mod(func(q *Query) {
q.end = c
})
}
// Eq adds one or more equality restrictions to the query.
//
// Equality filters interact with multiply-defined properties by ensuring that
// the given field has /at least one/ value which is equal to the specified
// constraint.
//
// So a query with `.Eq("thing", 1, 2)` will only return entities where the
// field "thing" is multiply defined and contains both a value of 1 and a value
// of 2.
//
// `Eq("thing", 1).Eq("thing", 2)` and `.Eq("thing", 1, 2)` have identical
// meaning.
func (q *Query) Eq(field string, values ...interface{}) *Query {
if len(values) == 0 {
return q
}
return q.mod(func(q *Query) {
if !q.reserved(field) {
if q.eqFilts == nil {
q.eqFilts = make(map[string]PropertySlice, 1)
}
s := q.eqFilts[field]
for _, value := range values {
p := Property{}
if q.err = p.SetValue(value, ShouldIndex); q.err != nil {
return
}
idx := sort.Search(len(s), func(i int) bool {
// s[i] >= p is the same as:
return s[i].Equal(&p) || p.Less(&s[i])
})
if idx == len(s) || !s[idx].Equal(&p) {
s = append(s, Property{})
copy(s[idx+1:], s[idx:])
s[idx] = p
}
}
q.eqFilts[field] = s
}
})
}
func (q *Query) reserved(field string) bool {
if field == "__key__" || field == "__scatter__" {
return false
}
if field == "" {
q.err = fmt.Errorf(
"cannot filter/project on: %q", field)
return true
}
if strings.HasPrefix(field, "__") && strings.HasSuffix(field, "__") {
q.err = fmt.Errorf(
"cannot filter/project on reserved property: %q", field)
return true
}
return false
}
func (q *Query) ineqOK(field string, value Property) bool {
if q.reserved(field) {
return false
}
if field == "__key__" && value.Type() != PTKey {
q.err = fmt.Errorf(
"filters on %q must have type *Key (got %s)", field, value.Type())
return false
}
if q.ineqFiltProp != "" && q.ineqFiltProp != field {
q.err = ErrMultipleInequalityFilter
return false
}
return true
}
// Lt imposes a 'less-than' inequality restriction on the Query.
//
// Inequality filters interact with multiply-defined properties by ensuring that
// the given field has /exactly one/ value which matches /all/ of the inequality
// constraints.
//
// So a query with `.Gt("thing", 5).Lt("thing", 10)` will only return entities
// where the field "thing" has a single value where `5 < val < 10`.
func (q *Query) Lt(field string, value interface{}) *Query {
p := Property{}
err := p.SetValue(value, ShouldIndex)
if err == nil && q.ineqFiltHighSet {
if q.ineqFiltHigh.Less(&p) {
return q
} else if q.ineqFiltHigh.Equal(&p) && !q.ineqFiltHighIncl {
return q
}
}
return q.mod(func(q *Query) {
if q.err = err; err != nil {
return
}
if q.ineqOK(field, p) {
q.ineqFiltProp = field
q.ineqFiltHighSet = true
q.ineqFiltHigh = p
q.ineqFiltHighIncl = false
}
})
}
// Lte imposes a 'less-than-or-equal' inequality restriction on the Query.
//
// Inequality filters interact with multiply-defined properties by ensuring that
// the given field has /exactly one/ value which matches /all/ of the inequality
// constraints.
//
// So a query with `.Gt("thing", 5).Lt("thing", 10)` will only return entities
// where the field "thing" has a single value where `5 < val < 10`.
func (q *Query) Lte(field string, value interface{}) *Query {
p := Property{}
err := p.SetValue(value, ShouldIndex)
if err == nil && q.ineqFiltHighSet {
if q.ineqFiltHigh.Less(&p) {
return q
} else if q.ineqFiltHigh.Equal(&p) {
return q
}
}
return q.mod(func(q *Query) {
if q.err = err; err != nil {
return
}
if q.ineqOK(field, p) {
q.ineqFiltProp = field
q.ineqFiltHighSet = true
q.ineqFiltHigh = p
q.ineqFiltHighIncl = true
}
})
}
// Gt imposes a 'greater-than' inequality restriction on the Query.
//
// Inequality filters interact with multiply-defined properties by ensuring that
// the given field has /exactly one/ value which matches /all/ of the inequality
// constraints.
//
// So a query with `.Gt("thing", 5).Lt("thing", 10)` will only return entities
// where the field "thing" has a single value where `5 < val < 10`.
func (q *Query) Gt(field string, value interface{}) *Query {
p := Property{}
err := p.SetValue(value, ShouldIndex)
if err == nil && q.ineqFiltLowSet {
if p.Less(&q.ineqFiltLow) {
return q
} else if p.Equal(&q.ineqFiltLow) && !q.ineqFiltLowIncl {
return q
}
}
return q.mod(func(q *Query) {
if q.err = err; err != nil {
return
}
if q.ineqOK(field, p) {
q.ineqFiltProp = field
q.ineqFiltLowSet = true
q.ineqFiltLow = p
q.ineqFiltLowIncl = false
}
})
}
// Gte imposes a 'greater-than-or-equal' inequality restriction on the Query.
//
// Inequality filters interact with multiply-defined properties by ensuring that
// the given field has /exactly one/ value which matches /all/ of the inequality
// constraints.
//
// So a query with `.Gt("thing", 5).Lt("thing", 10)` will only return entities
// where the field "thing" has a single value where `5 < val < 10`.
func (q *Query) Gte(field string, value interface{}) *Query {
p := Property{}
err := p.SetValue(value, ShouldIndex)
if err == nil && q.ineqFiltLowSet {
if p.Less(&q.ineqFiltLow) {
return q
} else if p.Equal(&q.ineqFiltLow) {
return q
}
}
return q.mod(func(q *Query) {
if q.err = err; err != nil {
return
}
if q.ineqOK(field, p) {
q.ineqFiltProp = field
q.ineqFiltLowSet = true
q.ineqFiltLow = p
q.ineqFiltLowIncl = true
}
})
}
// ClearFilters clears all equality and inequality filters from the Query. It
// does not clear the Ancestor filter if one is defined.
func (q *Query) ClearFilters() *Query {
return q.mod(func(q *Query) {
anc := q.eqFilts["__ancestor__"]
if anc != nil {
q.eqFilts = map[string]PropertySlice{"__ancestor__": anc}
} else {
q.eqFilts = nil
}
q.ineqFiltLowSet = false
q.ineqFiltHighSet = false
})
}
// Finalize converts this Query to a FinalizedQuery. If the Query has any
// inconsistencies or violates any of the query rules, that will be returned
// here.
func (q *Query) Finalize() (*FinalizedQuery, error) {
if q.err != nil {
return nil, q.err
}
q.finalizeOnce.Do(func() {
q.finalized, q.finalizeErr = q.finalizeImpl()
})
return q.finalized, q.finalizeErr
}
func (q *Query) finalizeImpl() (*FinalizedQuery, error) {
ancestor := (*Key)(nil)
if slice, ok := q.eqFilts["__ancestor__"]; ok {
ancestor = slice[0].Value().(*Key)
}
err := func() error {
if q.kind == "" { // kindless query checks
if q.ineqFiltProp != "" && q.ineqFiltProp != "__key__" {
return fmt.Errorf(
"kindless queries can only filter on __key__, got %q", q.ineqFiltProp)
}
allowedEqs := 0
if ancestor != nil {
allowedEqs = 1
}
if len(q.eqFilts) > allowedEqs {
return fmt.Errorf("kindless queries may not have any equality filters")
}
for _, o := range q.order {
if o.Property != "__key__" || o.Descending {
return fmt.Errorf("invalid order for kindless query: %#v", o)
}
}
}
if q.keysOnly && q.project != nil && q.project.Len() > 0 {
return errors.New("cannot project a keysOnly query")
}
if q.ineqFiltProp != "" {
if len(q.order) > 0 && q.order[0].Property != q.ineqFiltProp {
return fmt.Errorf(
"first sort order must match inequality filter: %q v %q",
q.order[0].Property, q.ineqFiltProp)
}
if q.ineqFiltLowSet && q.ineqFiltHighSet {
if q.ineqFiltHigh.Less(&q.ineqFiltLow) ||
(q.ineqFiltHigh.Equal(&q.ineqFiltLow) &&
(!q.ineqFiltLowIncl || !q.ineqFiltHighIncl)) {
return ErrNullQuery
}
}
if q.ineqFiltProp == "__key__" {
if q.ineqFiltLowSet {
if ancestor != nil && !q.ineqFiltLow.Value().(*Key).HasAncestor(ancestor) {
return fmt.Errorf(
"inequality filters on __key__ must be descendants of the __ancestor__")
}
}
if q.ineqFiltHighSet {
if ancestor != nil && !q.ineqFiltHigh.Value().(*Key).HasAncestor(ancestor) {
return fmt.Errorf(
"inequality filters on __key__ must be descendants of the __ancestor__")
}
}
}
}
err := error(nil)
if q.project != nil {
q.project.Iter(func(p string) bool {
if _, iseq := q.eqFilts[p]; iseq {
err = fmt.Errorf("cannot project on equality filter field: %s", p)
return false
}
return true
})
}
return err
}()
if err != nil {
return nil, err
}
ret := &FinalizedQuery{
original: q,
kind: q.kind,
keysOnly: q.keysOnly,
eventuallyConsistent: q.eventualConsistency || ancestor == nil,
limit: q.limit,
offset: q.offset,
start: q.start,
end: q.end,
eqFilts: q.eqFilts,
ineqFiltProp: q.ineqFiltProp,
ineqFiltLow: q.ineqFiltLow,
ineqFiltLowIncl: q.ineqFiltLowIncl,
ineqFiltLowSet: q.ineqFiltLowSet,
ineqFiltHigh: q.ineqFiltHigh,
ineqFiltHighIncl: q.ineqFiltHighIncl,
ineqFiltHighSet: q.ineqFiltHighSet,
}
// If a starting cursor is provided, ignore the offset, as it would have been
// accounted for in the query that produced the cursor.
if ret.start != nil {
ret.offset = nil
}
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))
// if len(q.order) > 0, we already enforce that the first order
// is the same as the inequality above. Otherwise we need to add it.
if len(q.order) == 0 && q.ineqFiltProp != "" {
ret.orders = []IndexColumn{{Property: q.ineqFiltProp}}
seenOrders.Add(q.ineqFiltProp)
}
// drop orders where there's an equality filter
// https://cloud.google.com/appengine/docs/go/datastore/queries#sort_orders_are_ignored_on_properties_with_equality_filters
// Deduplicate orders
for _, o := range q.order {
if _, iseq := q.eqFilts[o.Property]; !iseq {
if seenOrders.Add(o.Property) {
ret.orders = append(ret.orders, o)
}
}
}
// Add any projection columns not mentioned in the user-defined order as
// ASCENDING orders. Technically we could be smart and automatically use
// a DESCENDING ordered index, if it fit, but the logic gets insane, since all
// suffixes of all used indexes need to be PRECISELY equal (and so you'd have
// to hunt/invalidate/something to find the combination of indexes that are
// compatible with each other as well as the query). If you want to use
// a DESCENDING column, just add it to the user sort order, and this loop will
// not synthesize a new suffix entry for it.
//
// NOTE: if you want to use an index that sorts by -__key__, you MUST
// include all of the projected fields for that index in the order explicitly.
// Otherwise the generated orders will be wacky. So:
// Query("Foo").Project("A", "B").Order("A").Order("-__key__")
//
// will turn into a orders of:
// A, ASCENDING
// __key__, DESCENDING
// B, ASCENDING
// __key__, ASCENDING
//
// To prevent this, your query should have another Order("B") clause before
// the -__key__ clause.
if len(ret.project) > 0 {
sort.Strings(ret.project)
for _, p := range ret.project {
if !seenOrders.Has(p) {
ret.orders = append(ret.orders, IndexColumn{Property: p})
}
}
}
// If the suffix format ends with __key__ already (e.g. .Order("__key__")),
// then we're good to go. Otherwise we need to add it as the last bit of the
// suffix, since all indexes implicitly have it as the last column.
if len(ret.orders) == 0 || ret.orders[len(ret.orders)-1].Property != "__key__" {
ret.orders = append(ret.orders, IndexColumn{Property: "__key__"})
}
return ret, nil
}
func (q *Query) String() string {
ret := &bytes.Buffer{}
needComma := false
p := func(fmtStr string, stuff ...interface{}) {
if needComma {
if _, err := ret.WriteString(", "); err != nil {
panic(err)
}
}
needComma = true
fmt.Fprintf(ret, fmtStr, stuff...)
}
if _, err := ret.WriteString("Query("); err != nil {
panic(err)
}
if q.err != nil {
p("ERROR=%q", q.err.Error())
}
// Filters
if q.kind != "" {
p("Kind=%q", q.kind)
}
if q.eqFilts["__ancestor__"] != nil {
p("Ancestor=%s", q.eqFilts["__ancestor__"][0].Value().(*Key).String())
}
for prop, vals := range q.eqFilts {
if prop == "__ancestor__" {
continue
}
for _, v := range vals {
p("Filter(%q == %s)", prop, v.GQL())
}
}
if q.ineqFiltProp != "" {
if q.ineqFiltLowSet {
op := ">"
if q.ineqFiltLowIncl {
op = ">="
}
p("Filter(%q %s %s)", q.ineqFiltProp, op, q.ineqFiltLow.GQL())
}
if q.ineqFiltHighSet {
op := "<"
if q.ineqFiltHighIncl {
op = "<="
}
p("Filter(%q %s %s)", q.ineqFiltProp, op, q.ineqFiltHigh.GQL())
}
}
// Order
if len(q.order) > 0 {
orders := make([]string, len(q.order))
for i, o := range q.order {
orders[i] = o.String()
}
p("Order(%s)", strings.Join(orders, ", "))
}
// Projection
if q.project != nil && q.project.Len() > 0 {
f := "Project(%s)"
if q.distinct {
f = "Project[DISTINCT](%s)"
}
p(f, strings.Join(q.project.ToSlice(), ", "))
}
// Cursors
if q.start != nil {
p("Start(%q)", q.start.String())
}
if q.end != nil {
p("End(%q)", q.end.String())
}
// Modifiiers
if q.limit != nil {
p("Limit=%d", *q.limit)
}
if q.offset != nil {
p("Offset=%d", *q.offset)
}
if q.eventualConsistency {
p("EventualConsistency")
}
if q.keysOnly {
p("KeysOnly")
}
if _, err := ret.WriteRune(')'); err != nil {
panic(err)
}
return ret.String()
}