Skip to content

[Fix] Explaining a query with bindings requires bindVars to be set. #168

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 1 commit into from
May 20, 2021
Merged
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
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