Skip to content

Commit aecc467

Browse files
committed
Merging stats field together with plan.
1 parent 4a45183 commit aecc467

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

arango/aql.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,19 @@ def response_handler(resp: Response) -> Union[Json, Jsons]:
213213
if not resp.is_success:
214214
raise AQLQueryExplainError(resp, request)
215215
if "plan" in resp.body:
216-
plan: Json = resp.body["plan"]
217-
return plan
216+
result: Json = resp.body["plan"]
217+
if "stats" in resp.body:
218+
result["stats"] = resp.body["stats"]
219+
return result
218220
else:
219-
plans: Jsons = resp.body["plans"]
220-
return plans
221+
results: Jsons = resp.body["plans"]
222+
if "stats" in resp.body:
223+
# Although "plans" contains an array, "stats" is a single object.
224+
# We need to duplicate "stats" for each plan in order to preserve
225+
# the original structure.
226+
for plan in results:
227+
plan["stats"] = resp.body["stats"]
228+
return results
221229

222230
return self._execute(request, response_handler)
223231

tests/test_aql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def test_aql_query_management(db, bad_db, col, docs):
3333
"rules",
3434
"variables",
3535
"collections",
36+
"stats",
3637
]
3738
# Test explain invalid query
3839
with assert_raises(AQLQueryExplainError) as err:

0 commit comments

Comments
 (0)