@@ -655,6 +655,36 @@ def test_drop_schema(make_mocked_engine_adapter: t.Callable):
655655 ]
656656
657657
658+ def test_drop_schema_with_special_identifiers (make_mocked_engine_adapter : t .Callable ):
659+ adapter = make_mocked_engine_adapter (MSSQLEngineAdapter )
660+
661+ adapter ._get_data_objects = mock .Mock ()
662+ adapter ._get_data_objects .return_value = [
663+ DataObject (
664+ catalog = "test_catalog" ,
665+ schema = "test schema" , # Schema with space
666+ name = "test view" , # Object with space
667+ type = DataObjectType .from_str ("VIEW" ),
668+ ),
669+ DataObject (
670+ catalog = "test_catalog" ,
671+ schema = "test schema" ,
672+ name = "test table" , # Table with space
673+ type = DataObjectType .from_str ("TABLE" ),
674+ ),
675+ ]
676+
677+ schema_name = exp .to_table ("[test schema]" , dialect = "tsql" )
678+ adapter .drop_schema (schema_name , cascade = True )
679+
680+ # Validate that names with spaces/special chars are properly quoted with square brackets
681+ assert to_sql_calls (adapter ) == [
682+ """DROP VIEW IF EXISTS [test schema].[test view];""" ,
683+ """DROP TABLE IF EXISTS [test schema].[test table];""" ,
684+ """DROP SCHEMA IF EXISTS [test schema];""" ,
685+ ]
686+
687+
658688def test_df_dates (make_mocked_engine_adapter : t .Callable ):
659689 adapter = make_mocked_engine_adapter (MSSQLEngineAdapter )
660690
0 commit comments