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