Skip to content

Commit 977164a

Browse files
Fix execute commits on connection (some versions don't have commit on connection object)
1 parent 71a9446 commit 977164a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/test_core.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def test_query_tag_appears_in_query_history():
216216
try:
217217
with engine.connect() as conn:
218218
# Execute a simple query
219-
conn.execute(text("SELECT 1; -- query tag test"))
220-
conn.commit()
219+
with conn.begin():
220+
conn.execute(text("SELECT 1; -- query tag test"))
221221

222222
# Query the query history to verify the tag
223223
result = conn.execute(
@@ -246,19 +246,19 @@ def test_query_tag_per_query():
246246
try:
247247
with engine.connect() as conn:
248248
# Set query_tag for first set of operations
249-
conn.execute(text("ALTER SESSION SET QUERY_TAG = 'batch_job_1'"))
250-
conn.execute(text("SELECT 1; -- batch 1 query"))
251-
conn.commit()
249+
with conn.begin():
250+
conn.execute(text("ALTER SESSION SET QUERY_TAG = 'batch_job_1'"))
251+
conn.execute(text("SELECT 1; -- batch 1 query"))
252252

253253
# Change query_tag for second set of operations
254-
conn.execute(text("ALTER SESSION SET QUERY_TAG = 'batch_job_2'"))
255-
conn.execute(text("SELECT 2; -- batch 2 query"))
256-
conn.commit()
254+
with conn.begin():
255+
conn.execute(text("ALTER SESSION SET QUERY_TAG = 'batch_job_2'"))
256+
conn.execute(text("SELECT 2; -- batch 2 query"))
257257

258258
# Reset query_tag (unset it)
259-
conn.execute(text("ALTER SESSION UNSET QUERY_TAG"))
260-
conn.execute(text("SELECT 3; -- no tag query"))
261-
conn.commit()
259+
with conn.begin():
260+
conn.execute(text("ALTER SESSION UNSET QUERY_TAG"))
261+
conn.execute(text("SELECT 3; -- no tag query"))
262262

263263
# Verify the query tags in history
264264
result = conn.execute(

0 commit comments

Comments
 (0)