Add psycopg2 native tags to sqlcommenter (#1203)

This commit is contained in:
Thiyagu55
2022-07-30 05:14:47 +05:30
committed by GitHub
parent 7c75b3867b
commit fbac424515
5 changed files with 123 additions and 7 deletions

View File

@ -229,8 +229,20 @@ class TestDBApiIntegration(TestBase):
)
def test_executemany_comment(self):
connect_module = mock.MagicMock()
connect_module.__version__ = mock.MagicMock()
connect_module.__libpq_version__ = 123
connect_module.apilevel = 123
connect_module.threadsafety = 123
connect_module.paramstyle = "test"
db_integration = dbapi.DatabaseApiIntegration(
"testname", "testcomponent", enable_commenter=True
"testname",
"testcomponent",
enable_commenter=True,
commenter_options={"db_driver": False, "dbapi_level": False},
connect_module=connect_module,
)
mock_connection = db_integration.wrapped_connection(
mock_connect, {}, {}
@ -239,7 +251,7 @@ class TestDBApiIntegration(TestBase):
cursor.executemany("Select 1;")
self.assertRegex(
cursor.query,
r"Select 1 /\*traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
r"Select 1 /\*dbapi_threadsafety=123,driver_paramstyle='test',libpq_version=123,traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
)
def test_callproc(self):