@@ -439,7 +439,7 @@ def offset(self, num_to_skip):
439
439
all_descendants = self ._all_descendants ,
440
440
)
441
441
442
- def _check_snapshot (self , document_fields ):
442
+ def _check_snapshot (self , document_snapshot ):
443
443
"""Validate local snapshots for non-collection-group queries.
444
444
445
445
Raises:
@@ -449,26 +449,26 @@ def _check_snapshot(self, document_fields):
449
449
if self ._all_descendants :
450
450
return
451
451
452
- if document_fields .reference ._path [:- 1 ] != self ._parent ._path :
452
+ if document_snapshot .reference ._path [:- 1 ] != self ._parent ._path :
453
453
raise ValueError ("Cannot use snapshot from another collection as a cursor." )
454
454
455
- def _cursor_helper (self , document_fields , before , start ):
455
+ def _cursor_helper (self , document_fields_or_snapshot , before , start ):
456
456
"""Set values to be used for a ``start_at`` or ``end_at`` cursor.
457
457
458
458
The values will later be used in a query protobuf.
459
459
460
- When the query is sent to the server, the ``document_fields `` will
460
+ When the query is sent to the server, the ``document_fields_or_snapshot `` will
461
461
be used in the order given by fields set by
462
462
:meth:`~google.cloud.firestore_v1.query.Query.order_by`.
463
463
464
464
Args:
465
- document_fields
465
+ document_fields_or_snapshot
466
466
(Union[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`, dict, list, tuple]):
467
467
a document snapshot or a dictionary/list/tuple of fields
468
468
representing a query results cursor. A cursor is a collection
469
469
of values that represent a position in a query result set.
470
470
before (bool): Flag indicating if the document in
471
- ``document_fields `` should (:data:`False`) or
471
+ ``document_fields_or_snapshot `` should (:data:`False`) or
472
472
shouldn't (:data:`True`) be included in the result set.
473
473
start (Optional[bool]): determines if the cursor is a ``start_at``
474
474
cursor (:data:`True`) or an ``end_at`` cursor (:data:`False`).
@@ -478,15 +478,15 @@ def _cursor_helper(self, document_fields, before, start):
478
478
A query with cursor. Acts as a copy of the current query, modified
479
479
with the newly added "start at" cursor.
480
480
"""
481
- if isinstance (document_fields , tuple ):
482
- document_fields = list (document_fields )
483
- elif isinstance (document_fields , document .DocumentSnapshot ):
484
- self ._check_snapshot (document_fields )
481
+ if isinstance (document_fields_or_snapshot , tuple ):
482
+ document_fields_or_snapshot = list (document_fields_or_snapshot )
483
+ elif isinstance (document_fields_or_snapshot , document .DocumentSnapshot ):
484
+ self ._check_snapshot (document_fields_or_snapshot )
485
485
else :
486
486
# NOTE: We copy so that the caller can't modify after calling.
487
- document_fields = copy .deepcopy (document_fields )
487
+ document_fields_or_snapshot = copy .deepcopy (document_fields_or_snapshot )
488
488
489
- cursor_pair = document_fields , before
489
+ cursor_pair = document_fields_or_snapshot , before
490
490
query_kwargs = {
491
491
"projection" : self ._projection ,
492
492
"field_filters" : self ._field_filters ,
@@ -504,23 +504,23 @@ def _cursor_helper(self, document_fields, before, start):
504
504
505
505
return self .__class__ (self ._parent , ** query_kwargs )
506
506
507
- def start_at (self , document_fields ):
507
+ def start_at (self , document_fields_or_snapshot ):
508
508
"""Start query results at a particular document value.
509
509
510
510
The result set will **include** the document specified by
511
- ``document_fields ``.
511
+ ``document_fields_or_snapshot ``.
512
512
513
513
If the current query already has specified a start cursor -- either
514
514
via this method or
515
515
:meth:`~google.cloud.firestore_v1.query.Query.start_after` -- this
516
516
will overwrite it.
517
517
518
- When the query is sent to the server, the ``document_fields `` will
518
+ When the query is sent to the server, the ``document_fields_or_snapshot `` will
519
519
be used in the order given by fields set by
520
520
:meth:`~google.cloud.firestore_v1.query.Query.order_by`.
521
521
522
522
Args:
523
- document_fields
523
+ document_fields_or_snapshot
524
524
(Union[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`, dict, list, tuple]):
525
525
a document snapshot or a dictionary/list/tuple of fields
526
526
representing a query results cursor. A cursor is a collection
@@ -532,25 +532,25 @@ def start_at(self, document_fields):
532
532
a copy of the current query, modified with the newly added
533
533
"start at" cursor.
534
534
"""
535
- return self ._cursor_helper (document_fields , before = True , start = True )
535
+ return self ._cursor_helper (document_fields_or_snapshot , before = True , start = True )
536
536
537
- def start_after (self , document_fields ):
537
+ def start_after (self , document_fields_or_snapshot ):
538
538
"""Start query results after a particular document value.
539
539
540
540
The result set will **exclude** the document specified by
541
- ``document_fields ``.
541
+ ``document_fields_or_snapshot ``.
542
542
543
543
If the current query already has specified a start cursor -- either
544
544
via this method or
545
545
:meth:`~google.cloud.firestore_v1.query.Query.start_at` -- this will
546
546
overwrite it.
547
547
548
- When the query is sent to the server, the ``document_fields `` will
548
+ When the query is sent to the server, the ``document_fields_or_snapshot `` will
549
549
be used in the order given by fields set by
550
550
:meth:`~google.cloud.firestore_v1.query.Query.order_by`.
551
551
552
552
Args:
553
- document_fields
553
+ document_fields_or_snapshot
554
554
(Union[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`, dict, list, tuple]):
555
555
a document snapshot or a dictionary/list/tuple of fields
556
556
representing a query results cursor. A cursor is a collection
@@ -561,25 +561,27 @@ def start_after(self, document_fields):
561
561
A query with cursor. Acts as a copy of the current query, modified
562
562
with the newly added "start after" cursor.
563
563
"""
564
- return self ._cursor_helper (document_fields , before = False , start = True )
564
+ return self ._cursor_helper (
565
+ document_fields_or_snapshot , before = False , start = True
566
+ )
565
567
566
- def end_before (self , document_fields ):
568
+ def end_before (self , document_fields_or_snapshot ):
567
569
"""End query results before a particular document value.
568
570
569
571
The result set will **exclude** the document specified by
570
- ``document_fields ``.
572
+ ``document_fields_or_snapshot ``.
571
573
572
574
If the current query already has specified an end cursor -- either
573
575
via this method or
574
576
:meth:`~google.cloud.firestore_v1.query.Query.end_at` -- this will
575
577
overwrite it.
576
578
577
- When the query is sent to the server, the ``document_fields `` will
579
+ When the query is sent to the server, the ``document_fields_or_snapshot `` will
578
580
be used in the order given by fields set by
579
581
:meth:`~google.cloud.firestore_v1.query.Query.order_by`.
580
582
581
583
Args:
582
- document_fields
584
+ document_fields_or_snapshot
583
585
(Union[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`, dict, list, tuple]):
584
586
a document snapshot or a dictionary/list/tuple of fields
585
587
representing a query results cursor. A cursor is a collection
@@ -590,25 +592,27 @@ def end_before(self, document_fields):
590
592
A query with cursor. Acts as a copy of the current query, modified
591
593
with the newly added "end before" cursor.
592
594
"""
593
- return self ._cursor_helper (document_fields , before = True , start = False )
595
+ return self ._cursor_helper (
596
+ document_fields_or_snapshot , before = True , start = False
597
+ )
594
598
595
- def end_at (self , document_fields ):
599
+ def end_at (self , document_fields_or_snapshot ):
596
600
"""End query results at a particular document value.
597
601
598
602
The result set will **include** the document specified by
599
- ``document_fields ``.
603
+ ``document_fields_or_snapshot ``.
600
604
601
605
If the current query already has specified an end cursor -- either
602
606
via this method or
603
607
:meth:`~google.cloud.firestore_v1.query.Query.end_before` -- this will
604
608
overwrite it.
605
609
606
- When the query is sent to the server, the ``document_fields `` will
610
+ When the query is sent to the server, the ``document_fields_or_snapshot `` will
607
611
be used in the order given by fields set by
608
612
:meth:`~google.cloud.firestore_v1.query.Query.order_by`.
609
613
610
614
Args:
611
- document_fields
615
+ document_fields_or_snapshot
612
616
(Union[:class:`~google.cloud.firestore_v1.document.DocumentSnapshot`, dict, list, tuple]):
613
617
a document snapshot or a dictionary/list/tuple of fields
614
618
representing a query results cursor. A cursor is a collection
@@ -619,7 +623,9 @@ def end_at(self, document_fields):
619
623
A query with cursor. Acts as a copy of the current query, modified
620
624
with the newly added "end at" cursor.
621
625
"""
622
- return self ._cursor_helper (document_fields , before = False , start = False )
626
+ return self ._cursor_helper (
627
+ document_fields_or_snapshot , before = False , start = False
628
+ )
623
629
624
630
def _filters_pb (self ):
625
631
"""Convert all the filters into a single generic Filter protobuf.
0 commit comments