File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4949def escape_metadata_catalog_name (
5050 catalog_name : Optional [str ], enabled : bool
5151) -> Optional [str ]:
52- """Escape unescaped underscores, preserving existing escapes and % wildcards ."""
52+ r """Match JDBC: escape _ unless immediately preceded by \; preserve % ."""
5353 if not enabled or catalog_name is None :
5454 return catalog_name
5555 return re .sub (r"(?<!\\)_" , r"\\_" , catalog_name )
Original file line number Diff line number Diff line change @@ -1861,6 +1861,17 @@ def test_sync_execute_leaves_rowcount_default_when_num_modified_rows_none():
18611861 ("a_b_c" , r"a\_b\_c" ),
18621862 (r"my\_catalog" , r"my\_catalog" ),
18631863 (r"a\_b_c%" , r"a\_b\_c%" ),
1864+ # Match JDBC: preserve the final \_ pair regardless of backslash parity.
1865+ pytest .param (
1866+ r"my\\_cat_tail" ,
1867+ r"my\\_cat\_tail" ,
1868+ id = "jdbc-even-backslash-run" ,
1869+ ),
1870+ pytest .param (
1871+ r"my\\\_cat_tail" ,
1872+ r"my\\\_cat\_tail" ,
1873+ id = "jdbc-odd-backslash-run" ,
1874+ ),
18641875 ],
18651876)
18661877def test_metadata_catalog_escaping (
Original file line number Diff line number Diff line change @@ -73,6 +73,17 @@ def retry_policy_factory():
7373 ("a_b_c" , r"a\_b\_c" ),
7474 (r"my\_catalog" , r"my\_catalog" ),
7575 (r"a\_b_c%" , r"a\_b\_c%" ),
76+ # Match JDBC: preserve the final \_ pair regardless of backslash parity.
77+ pytest .param (
78+ r"my\\_cat_tail" ,
79+ r"my\\_cat\_tail" ,
80+ id = "jdbc-even-backslash-run" ,
81+ ),
82+ pytest .param (
83+ r"my\\\_cat_tail" ,
84+ r"my\\\_cat\_tail" ,
85+ id = "jdbc-odd-backslash-run" ,
86+ ),
7687 ],
7788)
7889def test_metadata_catalog_escaping (
You can’t perform that action at this time.
0 commit comments