Skip to content
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

Bug when passing a query to execute that is a psycopg2 SQL object #377

Open
zschumacher opened this issue Sep 21, 2020 · 4 comments
Open

Comments

@zschumacher
Copy link

zschumacher commented Sep 21, 2020

When you pass a SQL object from psycopg2.sql, we run into an unexpected error in the is_sql_dirty function. When we hit the line that tries to do sql.lower(), we may have passed in a SQL object, resulting in packages/cacheops/transaction.py", line 113, in is_sql_dirty sql = sql.lower() AttributeError: 'Composed' object has no attribute 'lower'

Perhaps it would be reasonable to add a block such as

if isinstance(sql.SQL):
    sql = sql.as_string(self.connection)

Would love other thoughts on this.

@zschumacher zschumacher changed the title Bugs when passing a query to execute that is a psycopg2 SQL object Bugswhen passing a query to execute that is a psycopg2 SQL object Sep 21, 2020
@zschumacher zschumacher changed the title Bugswhen passing a query to execute that is a psycopg2 SQL object Bug when passing a query to execute that is a psycopg2 SQL object Sep 21, 2020
@Suor
Copy link
Owner

Suor commented Sep 22, 2020

Can you create a test?

@zmaktr
Copy link

zmaktr commented Apr 29, 2023

The issue still persists.

@Suor
Copy link
Owner

Suor commented May 3, 2023

A test will help to move it.

@Suor Suor reopened this May 3, 2023
spirkaa added a commit to spirkaa/gia-api that referenced this issue Dec 7, 2023
@courcelm
Copy link

Hit the same issue while using django-bulk-load.

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

No branches or pull requests

4 participants