Skip to content

Commit 37e57bb

Browse files
authored
Merge pull request #198 from UnitedIncome/psycopg2-quote-ident-fix
Unwrap context provided to psycopg2.extensions.quote_ident
2 parents 4689220 + a83b482 commit 37e57bb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

aws_xray_sdk/ext/psycopg2/patch.py

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def patch():
1818
'register_type',
1919
_xray_register_type_fix
2020
)
21+
wrapt.wrap_function_wrapper(
22+
'psycopg2.extensions',
23+
'quote_ident',
24+
_xray_register_type_fix
25+
)
2126

2227

2328
def _xray_traced_connect(wrapped, instance, args, kwargs):

tests/ext/psycopg2/test_psycopg2.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import psycopg2
22
import psycopg2.extras
33
import psycopg2.pool
4+
import psycopg2.sql
45

56
import pytest
67
import testing.postgresql
@@ -158,3 +159,17 @@ def test_register_extensions():
158159
' user=' + dsn['user'])
159160
assert psycopg2.extras.register_uuid(None, conn)
160161
assert psycopg2.extras.register_uuid(None, conn.cursor())
162+
163+
164+
def test_query_as_string():
165+
with testing.postgresql.Postgresql() as postgresql:
166+
url = postgresql.url()
167+
dsn = postgresql.dsn()
168+
conn = psycopg2.connect('dbname=' + dsn['database'] +
169+
' password=mypassword' +
170+
' host=' + dsn['host'] +
171+
' port=' + str(dsn['port']) +
172+
' user=' + dsn['user'])
173+
test_sql = psycopg2.sql.Identifier('test')
174+
assert test_sql.as_string(conn)
175+
assert test_sql.as_string(conn.cursor())

0 commit comments

Comments
 (0)