Skip to content

SQL section of toolbar assumes database supports explain #958

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

Open
drakej opened this issue Jun 15, 2017 · 5 comments
Open

SQL section of toolbar assumes database supports explain #958

drakej opened this issue Jun 15, 2017 · 5 comments

Comments

@drakej
Copy link

drakej commented Jun 15, 2017

The SQL section of the toolbar assumes that the database supports explain (probably MySQL is being assumed) and attempts to run the SQL query with explain which results in a 500 error. The toolbar should check the driver before making any such assumptions.

@matthiask
Copy link
Member

Postgres also suppors EXPLAIN. Which database are you referring to?

@drakej
Copy link
Author

drakej commented Jun 15, 2017

SQL Server but I'm sure there are other examples. For instance Oracle might not have that capability and a lot more than MySQL and Postgres are supported by django through ODBC. In fact I'm using django_pyodbc to connect to SQL Server.

@VidJa
Copy link

VidJa commented Jun 7, 2019

I'm testing django-debug-toolbar 2.0a1 and ran into this issue while using an Oracle backend
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number

djdt tries to run : QUERY = 'EXPLAIN SELECT....
while Oracle expects something like 'EXPLAIN PLAN FOR SELECT...' to get the execution plan
Note: I'm far from an oracle expert.

@matthiask
Copy link
Member

Django has some support for .explain() since 2017 (django/django@c1c163b), maybe we could leverage this.

Or maybe insert an additional clause here: https://github.com/jazzband/django-debug-toolbar/blob/58f374a426a6b10dcf86554f6d9c71226b4b350f/debug_toolbar/panels/sql/views.py#L47-L55 -- that should work too and is probably a smaller change.

@drakej
Copy link
Author

drakej commented Nov 6, 2019

@matthiask Definitely, if Django does the abstraction for you, then that's the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants