diff --git a/arango/collection.py b/arango/collection.py index 829b6e3..ba22924 100644 --- a/arango/collection.py +++ b/arango/collection.py @@ -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" @@ -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. @@ -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. diff --git a/arango/exceptions.py b/arango/exceptions.py index 28295b2..29bcdc1 100644 --- a/arango/exceptions.py +++ b/arango/exceptions.py @@ -1074,3 +1074,10 @@ class JWTRefreshError(ArangoClientError): class JWTExpiredError(ArangoClientError): """JWT token has expired.""" + + +################################### +# Parameter Validation Exceptions # +################################### +class SortValidationError(ArangoClientError): + """Invalid sort parameters.""" diff --git a/arango/utils.py b/arango/utils.py index 0b5add5..0a088bb 100644 --- a/arango/utils.py +++ b/arango/utils.py @@ -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 @@ -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 """