Description
We observe this issue using the sqlcommenter with the psycopg2 instrumentor. The commenter doesn't support all types of query execution in psycopg2.
Steps to reproduce
cursor.execute(sql.SQL("SELECT 1"))
What is the expected behavior?
Both cursor.execute(sql.SQL("SELECT 1"))
or cursor.execute("SELECT 1")
should work.
The sqlcommenter should be able to work with the psycopg2.sql.SQL() objects (which is a subclass of psycopg2.sql.Composable) passed into the cursor.execute()
.
What is the actual behavior?
cursor.execute(sql.SQL("SELECT 1"))
fails while cursor.execute("SELECT 1")
works.
The sqlcommenter assumes that a Python string
is passed in, and it will try to call .rstrip() on the query object. In case of a composable that is passed in, it would blow up and eventually caught in the execption.