You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am integrating cachalot with my project and everything works fine up until the point we use django's ORM to execute queries, but in some parts of our project we use Raw SQLs and that's where this issue is happening. We are using psycopg2 native composition utility called sql. Here the import for reference:
frompsycopg2importsql
Now this frames a Composed Object which when we try to execute using cursor like this:
We don't support that unfortunately, but feel free to add a small if statement for your case. In the meantime, you can use a utility function to temporarily disable cachalot.
Sure @Andrew-Chen-Wang , once I get some spare time will raise a PR for the above, I'll just raise a warning when encountering sql other than string, and let it execute without bothering caching. Does it sound good?
We're evaluating using the lib in our project and faced similar issue. We utilise psycopg2.sql API to make using raw SQL safer.
I can confirm that adding CACHALOT_INVALIDATE_RAW = False allows to workaround the issue.
In the meantime, you can use a utility function to temporarily disable cachalot. @Andrew-Chen-Wang if you were referring to cachalot.api.cachalot_disabled then it doesn't help, probably because cachalot.monkey_patch._patch_cursor only checks for CACHALOT_INVALIDATE_RAW and not the LOCAL_STORAGE.
What happened?
I am integrating cachalot with my project and everything works fine up until the point we use django's ORM to execute queries, but in some parts of our project we use Raw SQLs and that's where this issue is happening. We are using psycopg2 native composition utility called
sql
. Here the import for reference:Now this frames a Composed Object which when we try to execute using cursor like this:
explodes in the cursors monkey_patch code which does not expect a compose object.
What should've happened instead?
I expect that cachalot should just allow these queries to run naturally and avoid caching them or at least make it a configurable setting.
Steps to reproduce
Configure cachalot in a django project and try to run any query using Raw sql and psycopg2 sql package for example:
django~=3.2 database=postgres 13.2
The text was updated successfully, but these errors were encountered: