Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions google/cloud/firestore_v1/types/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,30 @@ class StructuredQuery(proto.Message):
order_by (Sequence[google.cloud.firestore_v1.types.StructuredQuery.Order]):
The order to apply to the query results.

Firestore allows callers to provide a full ordering, a
partial ordering, or no ordering at all. In all cases,
Firestore guarantees a stable ordering through the following
rules:

- Any field required to appear in ``order_by``, that is not
already specified in ``order_by``, is appended to the
order in field name order by default.
- The ``order_by`` is required to reference all fields used
with an inequality filter.
- All fields that are required to be in the ``order_by``
but are not already present are appended in
lexicographical ordering of the field name.
- If an order on ``__name__`` is not specified, it is
appended by default.

Fields are appended with the same sort direction as the last
order specified, or 'ASCENDING' if no order was specified.
For example:

- ``SELECT * FROM Foo ORDER BY A`` becomes
``SELECT * FROM Foo ORDER BY A, __name__``
- ``SELECT * FROM Foo ORDER BY A DESC`` becomes
``SELECT * FROM Foo ORDER BY A DESC, __name__ DESC``
- ``SELECT * FROM Foo WHERE A > 1`` becomes
``SELECT * FROM Foo WHERE A > 1 ORDER BY A, __name__``
- ``ORDER BY a`` becomes ``ORDER BY a ASC, __name__ ASC``
- ``ORDER BY a DESC`` becomes
``ORDER BY a DESC, __name__ DESC``
- ``WHERE a > 1`` becomes
``WHERE a > 1 ORDER BY a ASC, __name__ ASC``
- ``WHERE __name__ > ... AND a > 1`` becomes
``WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC``
start_at (google.cloud.firestore_v1.types.Cursor):
A starting point for the query results.
end_at (google.cloud.firestore_v1.types.Cursor):
Expand Down