Skip to content

Improvements #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 9 additions & 5 deletions arango/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions arango/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
1 change: 1 addition & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down