Skip to content

Commit

Permalink
Merge pull request #168 from aquamatthias/mv/fix_explain_vars
Browse files Browse the repository at this point in the history
Add bind_vars parameter to AQL.explain method.
  • Loading branch information
joowani authored May 20, 2021
2 parents 9212461 + 864e759 commit ff990fd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion arango/aql.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def explain(
all_plans: bool = False,
max_plans: Optional[int] = None,
opt_rules: Optional[Sequence[str]] = None,
bind_vars: Optional[MutableMapping[str, str]] = None,
) -> Result[Union[Json, Jsons]]:
"""Inspect the query and return its metadata without executing it.
Expand All @@ -184,6 +185,8 @@ def explain(
:type max_plans: int
:param opt_rules: List of optimizer rules.
:type opt_rules: list
:param bind_vars: Bind variables for the query.
:type bind_vars: dict
:return: Execution plan, or plans if **all_plans** was set to True.
:rtype: dict | list
:raise arango.exceptions.AQLQueryExplainError: If explain fails.
Expand All @@ -194,10 +197,14 @@ def explain(
if opt_rules is not None:
options["optimizer"] = {"rules": opt_rules}

data: Json = {"query": query, "options": options}
if bind_vars is not None:
data["bindVars"] = bind_vars

request = Request(
method="post",
endpoint="/_api/explain",
data={"query": query, "options": options},
data=data,
)

def response_handler(resp: Response) -> Union[Json, Jsons]:
Expand Down

0 comments on commit ff990fd

Please sign in to comment.