Skip to content

Unwrap context provided to psycopg2.extensions.quote_ident #198

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

Merged
merged 1 commit into from Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aws_xray_sdk/ext/psycopg2/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def patch():
'register_type',
_xray_register_type_fix
)
wrapt.wrap_function_wrapper(
'psycopg2.extensions',
'quote_ident',
_xray_register_type_fix
)


def _xray_traced_connect(wrapped, instance, args, kwargs):
Expand Down
15 changes: 15 additions & 0 deletions tests/ext/psycopg2/test_psycopg2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import psycopg2
import psycopg2.extras
import psycopg2.pool
import psycopg2.sql

import pytest
import testing.postgresql
Expand Down Expand Up @@ -158,3 +159,17 @@ def test_register_extensions():
' user=' + dsn['user'])
assert psycopg2.extras.register_uuid(None, conn)
assert psycopg2.extras.register_uuid(None, conn.cursor())


def test_query_as_string():
with testing.postgresql.Postgresql() as postgresql:
url = postgresql.url()
dsn = postgresql.dsn()
conn = psycopg2.connect('dbname=' + dsn['database'] +
' password=mypassword' +
' host=' + dsn['host'] +
' port=' + str(dsn['port']) +
' user=' + dsn['user'])
test_sql = psycopg2.sql.Identifier('test')
assert test_sql.as_string(conn)
assert test_sql.as_string(conn.cursor())