@@ -10661,6 +10661,89 @@ def test_decimal_separator_calculations(cursor, db_connection):
1066110661 # Cleanup
1066210662 cursor .execute ("DROP TABLE IF EXISTS #pytest_decimal_calc_test" )
1066310663
10664+ def test_date_string_parameter_binding (cursor , db_connection ):
10665+ """Verify that date-like strings are treated as strings in parameter binding"""
10666+ table_name = "#pytest_date_string"
10667+ try :
10668+ drop_table_if_exists (cursor , table_name )
10669+ cursor .execute (f"""
10670+ CREATE TABLE { table_name } (
10671+ a_column VARCHAR(20)
10672+ )
10673+ """ )
10674+ cursor .execute (f"INSERT INTO { table_name } (a_column) VALUES ('string1'), ('string2')" )
10675+ db_connection .commit ()
10676+
10677+ date_str = "2025-08-12"
10678+
10679+ # Should fail to match anything, since binding may treat it as DATE not VARCHAR
10680+ cursor .execute (f"SELECT a_column FROM { table_name } WHERE RIGHT(a_column, 10) = ?" , (date_str ,))
10681+ rows = cursor .fetchall ()
10682+
10683+ assert rows == [], f"Expected no match for date-like string, got { rows } "
10684+
10685+ except Exception as e :
10686+ pytest .fail (f"Date string parameter binding test failed: { e } " )
10687+ finally :
10688+ drop_table_if_exists (cursor , table_name )
10689+ db_connection .commit ()
10690+
10691+ def test_time_string_parameter_binding (cursor , db_connection ):
10692+ """Verify that time-like strings are treated as strings in parameter binding"""
10693+ table_name = "#pytest_time_string"
10694+ try :
10695+ drop_table_if_exists (cursor , table_name )
10696+ cursor .execute (f"""
10697+ CREATE TABLE { table_name } (
10698+ time_col VARCHAR(22)
10699+ )
10700+ """ )
10701+ cursor .execute (f"INSERT INTO { table_name } (time_col) VALUES ('prefix_14:30:45_suffix')" )
10702+ db_connection .commit ()
10703+
10704+ time_str = "14:30:45"
10705+
10706+ # This should fail because '14:30:45' gets converted to TIME type
10707+ # and SQL Server can't compare TIME against VARCHAR with prefix/suffix
10708+ cursor .execute (f"SELECT time_col FROM { table_name } WHERE time_col = ?" , (time_str ,))
10709+ rows = cursor .fetchall ()
10710+
10711+ assert rows == [], f"Expected no match for time-like string, got { rows } "
10712+
10713+ except Exception as e :
10714+ pytest .fail (f"Time string parameter binding test failed: { e } " )
10715+ finally :
10716+ drop_table_if_exists (cursor , table_name )
10717+ db_connection .commit ()
10718+
10719+ def test_datetime_string_parameter_binding (cursor , db_connection ):
10720+ """Verify that datetime-like strings are treated as strings in parameter binding"""
10721+ table_name = "#pytest_datetime_string"
10722+ try :
10723+ drop_table_if_exists (cursor , table_name )
10724+ cursor .execute (f"""
10725+ CREATE TABLE { table_name } (
10726+ datetime_col VARCHAR(33)
10727+ )
10728+ """ )
10729+ cursor .execute (f"INSERT INTO { table_name } (datetime_col) VALUES ('prefix_2025-08-12T14:30:45_suffix')" )
10730+ db_connection .commit ()
10731+
10732+ datetime_str = "2025-08-12T14:30:45"
10733+
10734+ # This should fail because '2025-08-12T14:30:45' gets converted to TIMESTAMP type
10735+ # and SQL Server can't compare TIMESTAMP against VARCHAR with prefix/suffix
10736+ cursor .execute (f"SELECT datetime_col FROM { table_name } WHERE datetime_col = ?" , (datetime_str ,))
10737+ rows = cursor .fetchall ()
10738+
10739+ assert rows == [], f"Expected no match for datetime-like string, got { rows } "
10740+
10741+ except Exception as e :
10742+ pytest .fail (f"Datetime string parameter binding test failed: { e } " )
10743+ finally :
10744+ drop_table_if_exists (cursor , table_name )
10745+ db_connection .commit ()
10746+
1066410747def test_close (db_connection ):
1066510748 """Test closing the cursor"""
1066610749 try :
0 commit comments