Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update sort parameter type. add SortValidationError as custom exception
  • Loading branch information
Deniz Alpaslan committed Jan 30, 2025
commit 107df529b51c9905a7ce9ec0dd31787d5182da96
5 changes: 4 additions & 1 deletion arango/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ def all(
:return: Document cursor.
:rtype: arango.cursor.Cursor
:raise arango.exceptions.DocumentGetError: If retrieval fails.
:raise arango.exceptions.SortValidationError: If sort parameters are invalid.
"""
assert is_none_or_int(skip), "skip must be a non-negative int"
assert is_none_or_int(limit), "limit must be a non-negative int"
Expand Down Expand Up @@ -755,7 +756,7 @@ def find(
skip: Optional[int] = None,
limit: Optional[int] = None,
allow_dirty_read: bool = False,
sort: Sequence[Json] = [],
sort: Jsons = [],
) -> Result[Cursor]:
"""Return all documents that match the given filters.

Expand All @@ -767,6 +768,8 @@ def find(
:type limit: int | None
:param allow_dirty_read: Allow reads from followers in a cluster.
:type allow_dirty_read: bool
:param sort: Document sort parameters
:type sort: Jsons
:return: Document cursor.
:rtype: arango.cursor.Cursor
:raise arango.exceptions.DocumentGetError: If retrieval fails.
Expand Down
7 changes: 7 additions & 0 deletions arango/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,3 +1074,10 @@ class JWTRefreshError(ArangoClientError):

class JWTExpiredError(ArangoClientError):
"""JWT token has expired."""


###################################
# Parameter Validation Exceptions #
###################################
class SortValidationError(ArangoClientError):
"""Invalid sort parameters."""
6 changes: 3 additions & 3 deletions arango/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Any, Iterator, Sequence, Union

from arango.exceptions import DocumentParseError
from arango.typings import Json
from arango.typings import Json, Jsons


@contextmanager
Expand Down Expand Up @@ -148,11 +148,11 @@ def validate_sort_parameters(sort: Sequence[Json]) -> bool:
return True


def build_sort_expression(sort: Sequence[Json]) -> str:
def build_sort_expression(sort: Jsons) -> str:
"""Build a sort condition for an AQL query.

:param sort: Document sort parameters.
:type sort: Sequence[Json]
:type sort: Jsons
:return: The complete AQL sort condition.
:rtype: str
"""
Expand Down
Loading