Skip to content

Commit eebd6de

Browse files
committed
addressed review comments
1 parent 9b64b9f commit eebd6de

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/test_004_cursor.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7196,6 +7196,47 @@ def test_executemany_uuid_insert_and_select(cursor, db_connection):
71967196
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
71977197
db_connection.commit()
71987198

7199+
def test_executemany_uuid_roundtrip_fixed_value(cursor, db_connection):
7200+
"""Ensure a fixed canonical UUID round-trips exactly."""
7201+
table_name = "#pytest_uuid_fixed"
7202+
try:
7203+
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
7204+
cursor.execute(f"""
7205+
CREATE TABLE {table_name} (
7206+
id UNIQUEIDENTIFIER,
7207+
description NVARCHAR(50)
7208+
)
7209+
""")
7210+
db_connection.commit()
7211+
7212+
fixed_uuid = uuid.UUID("12345678-1234-5678-1234-567812345678")
7213+
description = "FixedUUID"
7214+
7215+
# Insert via executemany
7216+
cursor.executemany(
7217+
f"INSERT INTO {table_name} (id, description) VALUES (?, ?)",
7218+
[(fixed_uuid, description)]
7219+
)
7220+
db_connection.commit()
7221+
7222+
# Fetch back
7223+
cursor.execute(f"SELECT id, description FROM {table_name} WHERE description = ?", description)
7224+
row = cursor.fetchone()
7225+
retrieved_uuid, retrieved_desc = row
7226+
7227+
# Ensure type and value are correct
7228+
if isinstance(retrieved_uuid, str):
7229+
retrieved_uuid = uuid.UUID(retrieved_uuid)
7230+
7231+
assert isinstance(retrieved_uuid, uuid.UUID)
7232+
assert retrieved_uuid == fixed_uuid
7233+
assert str(retrieved_uuid) == str(fixed_uuid)
7234+
assert retrieved_desc == description
7235+
7236+
finally:
7237+
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
7238+
db_connection.commit()
7239+
71997240
def test_decimal_separator_with_multiple_values(cursor, db_connection):
72007241
"""Test decimal separator with multiple different decimal values"""
72017242
original_separator = mssql_python.getDecimalSeparator()

0 commit comments

Comments
 (0)