-
Notifications
You must be signed in to change notification settings - Fork 1.1k
list values incorrectly adapted in SQL panel #1831
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
Comments
Patch adjusted, drop _quote_expr() as well: |
@tkoschnick can you create a PR please? I'm pretty skeptical we can drop that quoting logic though. I'm curious how that change handles the test suite. |
I've investigated a bit further. The current quoting uses the Python representation, which happens to work for simple data types like ints and strings. For anything more complex, only the database driver's mogrify function is able to provide the correct adaptation. Take a more involved example, Postgres' range type. Currently, it's displayed as follows in the SQL panel:
correct as produced with the patch applied:
With the original example, list adaptation, the correct way depends on the database driver in use. Not patched:
psycopg3:
psycopg2:
I don't think there is a way to get this right without just passing it to mogrify. Tests all pass with the patch applied. |
I have a sql query containing
... WHERE id = ANY(%s)
and the param being a list, e.g.[1, 2]
.Adapted, the query looks like
id = ANY('{1,2}'::int2[])
, but in the SQL panel, it shows up asid = ANY('[1,2]')
. This is due to the parameters being quoted already before being passed to mogrify. Dropping the extra quoting step, the query shows up correctly in the SQL panel.Note that I've tested only with psycopg2/3, I don't know if other backends require the extra quoting.
tracking.txt
The text was updated successfully, but these errors were encountered: