Skip to content

Firestore: semantics using 'DocumentSnapshot' as cursor #6665

@tseaver

Description

@tseaver

The "cursor-related" methods (Query.start_at, Query.start_after, Query.end_before, Query.end_at) accept a DocumentSnapshot instance for their document_fields method, but do not apply all required ordering semantics:

  • Per this conformance test, for queries which do not explicitly have __name__ set in their order_by field, passing a DocumentSnapshot to a cursor-related method implies ordering based on __name__, in the same direction as the last explicitly-specified order_by field.
  • Per this conformance test, for queries with no order_by specified, passing a DocumentSnapshot to a cursor-related method implies ordering based on __name__ in ascending order.
  • Per this conformance test, whenever __name__ is already present in a query's order_by, passing a DocumentSnapshot to a cursor-related method does not change the query's order_by.
  • Per this conformance test, for queries with a where clause using an ordering operator but without a matching order_by field, passing a DocumentSnapshot to a cursor-related method must add order_by fields for both the where field and for __name__.
  • In any case where __name__ is present in order_by, the snapshot's fully-qualified reference path (in form projects/<PROJECT>/databases/<DATABASE>/<DATABASE-RELATIVE_PATH> is passed in the corresponding cursor field.
  • Per this conformance test, passing a DocumentSnapshot from a foreign collection to a cursor-related method must raise an error.

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the Firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions