diff --git a/CHANGELOG.md b/CHANGELOG.md index c4883b69..c589a712 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ main ---- -* Adding peak_memory_usage as a new property of AQL queries, available since ArangoDB 3.11. +* The db.version() now has a new optional parameter "details" that can be used to return additional information about + the server version. The default is still false, so the old behavior is preserved. + +* Added peak_memory_usage as a new property of AQL queries, available since ArangoDB 3.11. * The explain method of AQL queries includes the "stats" field in the returned object. Note that the REST API returns it separately from the "plan" field, but for now we have to merge them together to ensure backward compatibility. diff --git a/arango/database.py b/arango/database.py index 15204d43..da7ffc0a 100644 --- a/arango/database.py +++ b/arango/database.py @@ -300,21 +300,25 @@ def response_handler(resp: Response) -> Any: return self._execute(request, response_handler) - def version(self) -> Result[str]: + def version(self, details: bool = False) -> Result[Any]: """Return ArangoDB server version. - + :param details: Return more detailed version output + :type details: bool | None :return: Server version. :rtype: str :raise arango.exceptions.ServerVersionError: If retrieval fails. """ request = Request( - method="get", endpoint="/_api/version", params={"details": False} + method="get", endpoint="/_api/version", params={"details": details} ) - def response_handler(resp: Response) -> str: + def response_handler(resp: Response) -> Any: if not resp.is_success: raise ServerVersionError(resp, request) - return str(resp.body["version"]) + if not details: + return str(resp.body["version"]) + else: + return resp.body return self._execute(request, response_handler) diff --git a/arango/formatter.py b/arango/formatter.py index eb527ff3..09801026 100644 --- a/arango/formatter.py +++ b/arango/formatter.py @@ -902,6 +902,10 @@ def format_view(body: Json) -> Json: if "indexes" in body: result["indexes"] = body["indexes"] + # Introduced in 3.12 EE + if "optimizeTopK" in body: + result["optimizeTopK"] = body["optimizeTopK"] + return verify_format(body, result) diff --git a/tests/test_database.py b/tests/test_database.py index f56122c0..70d5af5b 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -68,6 +68,7 @@ def test_database_misc_methods(sys_db, db, bad_db): # Test get server version assert isinstance(db.version(), str) + assert isinstance(db.version(details=True), dict) # Test get server version with bad database with assert_raises(ServerVersionError) as err: