@@ -4407,31 +4407,25 @@ def test_xsqlite_if_exists(sqlite_buildin):
44074407class TestProcessSQLHints :
44084408 """Tests for _process_sql_hints helper function."""
44094409
4410- def test_process_sql_hints_oracle_list (self ):
4411- """Test hint processing with Oracle dialect and list input."""
4412- hints = {"oracle" : ["APPEND" , "PARALLEL" ]}
4413- result = sql ._process_sql_hints (hints , "oracle" )
4414- assert result == "/*+ APPEND PARALLEL */"
4415-
44164410 def test_process_sql_hints_oracle_string (self ):
4417- """Test hint processing with Oracle dialect and string input ."""
4418- hints = {"oracle" : "APPEND PARALLEL" }
4411+ """Test hint processing with Oracle dialect - user provides complete string ."""
4412+ hints = {"oracle" : "/*+ APPEND PARALLEL */ " }
44194413 result = sql ._process_sql_hints (hints , "oracle" )
44204414 assert result == "/*+ APPEND PARALLEL */"
44214415
4422- def test_process_sql_hints_preformatted (self ):
4423- """Test that pre-formatted hints are returned as-is ."""
4424- hints = {"oracle" : "/*+ APPEND PARALLEL */" }
4416+ def test_process_sql_hints_oracle_simple (self ):
4417+ """Test hint processing with simple Oracle hint string ."""
4418+ hints = {"oracle" : "/*+ PARALLEL */" }
44254419 result = sql ._process_sql_hints (hints , "oracle" )
4426- assert result == "/*+ APPEND PARALLEL */"
4420+ assert result == "/*+ PARALLEL */"
44274421
44284422 def test_process_sql_hints_case_insensitive (self ):
44294423 """Test that dialect names are case-insensitive."""
4430- hints = {"ORACLE" : [ " APPEND" ] }
4424+ hints = {"ORACLE" : "/*+ APPEND */" }
44314425 result = sql ._process_sql_hints (hints , "oracle" )
44324426 assert result == "/*+ APPEND */"
44334427
4434- hints = {"oracle" : [ " APPEND" ] }
4428+ hints = {"oracle" : "/*+ APPEND */" }
44354429 result = sql ._process_sql_hints (hints , "ORACLE" )
44364430 assert result == "/*+ APPEND */"
44374431
@@ -4459,9 +4453,20 @@ def test_process_sql_hints_mysql(self):
44594453
44604454 def test_process_sql_hints_mssql (self ):
44614455 """Test hint processing for SQL Server dialect."""
4462- hints = {"mssql" : "TABLOCK" }
4456+ hints = {"mssql" : "WITH ( TABLOCK) " }
44634457 result = sql ._process_sql_hints (hints , "mssql" )
4464- assert result == "TABLOCK"
4458+ assert result == "WITH (TABLOCK)"
4459+
4460+ def test_process_sql_hints_multiple_dialects (self ):
4461+ """Test extraction from dict with multiple dialects."""
4462+ hints = {
4463+ "oracle" : "/*+ PARALLEL */" ,
4464+ "mysql" : "DELAYED" ,
4465+ "postgresql" : "/* comment */" ,
4466+ }
4467+ assert sql ._process_sql_hints (hints , "oracle" ) == "/*+ PARALLEL */"
4468+ assert sql ._process_sql_hints (hints , "mysql" ) == "DELAYED"
4469+ assert sql ._process_sql_hints (hints , "postgresql" ) == "/* comment */"
44654470
44664471
44674472@pytest .mark .parametrize ("conn" , sqlalchemy_connectable )
@@ -4471,7 +4476,10 @@ def test_to_sql_with_hints_parameter(conn, test_frame1, request):
44714476
44724477 with pandasSQL_builder (conn , need_transaction = True ) as pandasSQL :
44734478 pandasSQL .to_sql (
4474- test_frame1 , "test_hints" , hints = {"oracle" : ["APPEND" ]}, if_exists = "replace"
4479+ test_frame1 ,
4480+ "test_hints" ,
4481+ hints = {"oracle" : "/*+ APPEND */" },
4482+ if_exists = "replace" ,
44754483 )
44764484 assert pandasSQL .has_table ("test_hints" )
44774485 assert count_rows (conn , "test_hints" ) == len (test_frame1 )
@@ -4505,7 +4513,7 @@ def sample(pd_table, conn, keys, data_iter):
45054513 test_frame1 ,
45064514 "test_hints_method" ,
45074515 method = sample ,
4508- hints = {"oracle" : [ " APPEND" ] },
4516+ hints = {"oracle" : "/*+ APPEND */" },
45094517 )
45104518 assert pandasSQL .has_table ("test_hints_method" )
45114519
@@ -4524,7 +4532,7 @@ def test_to_sql_hints_with_different_methods(conn, method, test_frame1, request)
45244532 test_frame1 ,
45254533 "test_hints_methods" ,
45264534 method = method ,
4527- hints = {"oracle" : [ " APPEND" , " PARALLEL" ] },
4535+ hints = {"oracle" : "/*+ APPEND PARALLEL */" },
45284536 if_exists = "replace" ,
45294537 )
45304538 assert pandasSQL .has_table ("test_hints_methods" )
@@ -4538,10 +4546,10 @@ def test_to_sql_hints_multidb_dict(conn, test_frame1, request):
45384546 conn = request .getfixturevalue (conn )
45394547
45404548 hints = {
4541- "oracle" : [ " APPEND" , " PARALLEL" ] ,
4549+ "oracle" : "/*+ APPEND PARALLEL */" ,
45424550 "mysql" : "HIGH_PRIORITY" ,
4543- "postgresql" : "some_pg_hint " ,
4544- "sqlite" : "ignored " ,
4551+ "postgresql" : "/* pg hint */ " ,
4552+ "sqlite" : "IGNORED " ,
45454553 }
45464554
45474555 with pandasSQL_builder (conn , need_transaction = True ) as pandasSQL :
@@ -4561,7 +4569,7 @@ def test_to_sql_hints_adbc_not_supported(sqlite_adbc_conn, test_frame1):
45614569 msg = "'hints' is not implemented for ADBC drivers"
45624570
45634571 with pytest .raises (NotImplementedError , match = msg ):
4564- df .to_sql ("test" , sqlite_adbc_conn , hints = {"oracle " : [ "APPEND" ] })
4572+ df .to_sql ("test" , sqlite_adbc_conn , hints = {"mysql " : "SOME_HINT" })
45654573
45664574
45674575def test_to_sql_hints_sqlite_builtin (sqlite_buildin , test_frame1 ):
0 commit comments