-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Error debugging GeoDjango queries #423
Comments
I'm not sure where the problem you're describing occurs. Is it in the EXPLAIN feature? |
Yes, in the views |
I looked at this in detail today I don't understand your example at all. If it worked, it would be an SQL injection. Parameters you pass to the database are escaped. It's incorrect to pass a parameter such as Here's how I have reproduced your example in a project of mine, slightly adapted because I'm using The following query works:
The following code in a view crashes:
The crash happens even before the code reaches the toolbar. There might be a bug in this area, but you haven't provided enough information for me to reproduce it. Please remember that I do not have access to your brain and your computer when reporting bugs. |
I have the same problem, using |
Without this fix, pushing the 'sel' or 'explain' button for a query containing some EWKB-encoded geometry as parameter results in this crash: ``` Internal Server Error: /__debug__/sql_explain/ Traceback (most recent call last): File "/Users/jieter/.pyenv/versions/obs/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) psycopg2.errors.InternalError_: parse error - invalid geometry LINE 1: ...ure" IN (0, 1, 5)) AND "waarneming"."geo_point" @ 'ST_GeomFr... ^ HINT: "ST" <-- parse error at position 2 within geometry ``` I'm not sure if this is the appropriate location in the code, but with this fix, both `sql_select` and `sql_explain` work without flaws. Previous PR adding a similar fix: django-commons#1130 Fixes: django-commons#423
Without this fix, pushing the 'sel' or 'explain' button for a query containing some EWKB-encoded geometry as parameter results in this crash: ``` Internal Server Error: /__debug__/sql_explain/ Traceback (most recent call last): File "/Users/jieter/.pyenv/versions/obs/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) psycopg2.errors.InternalError_: parse error - invalid geometry LINE 1: ...ure" IN (0, 1, 5)) AND "waarneming"."geo_point" @ 'ST_GeomFr... ^ HINT: "ST" <-- parse error at position 2 within geometry ``` I'm not sure if this is the appropriate location in the code, but with this fix, both `sql_select` and `sql_explain` work without flaws. Previous PR adding a similar fix: django-commons#1130 Fixes: django-commons#423
Without this fix, pushing the 'sel' or 'explain' button for a query containing some EWKB-encoded geometry as parameter results in this crash: ``` Internal Server Error: /__debug__/sql_explain/ Traceback (most recent call last): File "/Users/jieter/.pyenv/versions/obs/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) psycopg2.errors.InternalError_: parse error - invalid geometry LINE 1: ...ure" IN (0, 1, 5)) AND "waarneming"."geo_point" @ 'ST_GeomFr... ^ HINT: "ST" <-- parse error at position 2 within geometry ``` I'm not sure if this is the appropriate location in the code, but with this fix, both `sql_select` and `sql_explain` work without flaws. Previous PR adding a similar fix: #1130 Fixes: #423
Reopend as per #1547 |
I was impacted by this issue here #423 (comment), used this today and I was very surprised that just worked fine! I couldn't find it in the changelog but it seems you landed the fix in #1426 I think you can close this one @tim-schilling / @aaugustin Thank you very much guys!! |
@jperelli that change was reverted as it mutates data going into your database. You should upgrade versions of the toolbar. |
@tim-schilling You are right, sorry abot that. I can see it now in a query that uses a geom as a parameter |
When debugging queries that use GeoDjango they are parsed like normal strings.
Example:
What it should execute:
What it really executes:
I am using django-debug-toolbar version 0.9.4, Django 1.4 and PostgreSQL with PostGIS.
The text was updated successfully, but these errors were encountered: