You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using djangoql as example which does run queryset.explain will result in a ProgrammingError.
Reproducing would be easy by adding a queryset.explain in a view or installing djangoql and try to preform a search in the Django admin.
The generated SQL will contains two explains
syntax error at or near "EXPLAIN"
LINE 1: EXPLAIN EXPLAIN SELECT ...
This is caused by _explain_query and exactly this part
# currently we cannot use explain() method# for queries other than `select`prefixed_query=f"{prefix}{q}"withconnection.cursor() ascur:
cur.execute(prefixed_query, params)
result=_unpack_explanation(cur.fetchall())
return'\n'.join(result)
A possible way to fix this is to check if the SQL starts with explain and skip the check/analyze.
# currently we cannot use explain() method# for queries other than `select`# Skip explain queriesifq.lower().startswith('explain'):
returnNoneprefixed_query=f"{prefix}{q}"withconnection.cursor() ascur:
cur.execute(prefixed_query, params)
result=_unpack_explanation(cur.fetchall())
return'\n'.join(result)
If that's fine I can prepare a PR for this.
Thank you.
The text was updated successfully, but these errors were encountered:
Using djangoql as example which does run queryset.explain will result in a ProgrammingError.
Reproducing would be easy by adding a queryset.explain in a view or installing djangoql and try to preform a search in the Django admin.
The generated SQL will contains two explains
This is caused by
_explain_query
and exactly this partA possible way to fix this is to check if the SQL starts with explain and skip the check/analyze.
If that's fine I can prepare a PR for this.
Thank you.
The text was updated successfully, but these errors were encountered: