Skip to content

Commit 107df52

Browse files
author
Deniz Alpaslan
committed
update sort parameter type. add SortValidationError as custom exception
1 parent 32cdc62 commit 107df52

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

arango/collection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ def all(
720720
:return: Document cursor.
721721
:rtype: arango.cursor.Cursor
722722
:raise arango.exceptions.DocumentGetError: If retrieval fails.
723+
:raise arango.exceptions.SortValidationError: If sort parameters are invalid.
723724
"""
724725
assert is_none_or_int(skip), "skip must be a non-negative int"
725726
assert is_none_or_int(limit), "limit must be a non-negative int"
@@ -755,7 +756,7 @@ def find(
755756
skip: Optional[int] = None,
756757
limit: Optional[int] = None,
757758
allow_dirty_read: bool = False,
758-
sort: Sequence[Json] = [],
759+
sort: Jsons = [],
759760
) -> Result[Cursor]:
760761
"""Return all documents that match the given filters.
761762
@@ -767,6 +768,8 @@ def find(
767768
:type limit: int | None
768769
:param allow_dirty_read: Allow reads from followers in a cluster.
769770
:type allow_dirty_read: bool
771+
:param sort: Document sort parameters
772+
:type sort: Jsons
770773
:return: Document cursor.
771774
:rtype: arango.cursor.Cursor
772775
:raise arango.exceptions.DocumentGetError: If retrieval fails.

arango/exceptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,3 +1074,10 @@ class JWTRefreshError(ArangoClientError):
10741074

10751075
class JWTExpiredError(ArangoClientError):
10761076
"""JWT token has expired."""
1077+
1078+
1079+
###################################
1080+
# Parameter Validation Exceptions #
1081+
###################################
1082+
class SortValidationError(ArangoClientError):
1083+
"""Invalid sort parameters."""

arango/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import Any, Iterator, Sequence, Union
1313

1414
from arango.exceptions import DocumentParseError
15-
from arango.typings import Json
15+
from arango.typings import Json, Jsons
1616

1717

1818
@contextmanager
@@ -148,11 +148,11 @@ def validate_sort_parameters(sort: Sequence[Json]) -> bool:
148148
return True
149149

150150

151-
def build_sort_expression(sort: Sequence[Json]) -> str:
151+
def build_sort_expression(sort: Jsons) -> str:
152152
"""Build a sort condition for an AQL query.
153153
154154
:param sort: Document sort parameters.
155-
:type sort: Sequence[Json]
155+
:type sort: Jsons
156156
:return: The complete AQL sort condition.
157157
:rtype: str
158158
"""

0 commit comments

Comments
 (0)