django-cacheops icon indicating copy to clipboard operation
django-cacheops copied to clipboard

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

Open zschumacher opened this issue 3 years ago • 4 comments

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 avatar Sep 21 '20 20:09 zschumacher

Can you create a test?

Suor avatar Sep 22 '20 00:09 Suor

The issue still persists.

zmaktr avatar Apr 29 '23 12:04 zmaktr

A test will help to move it.

Suor avatar May 03 '23 06:05 Suor

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

courcelm avatar Jan 23 '24 16:01 courcelm