diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/dialect/mssql/test_compiler.py | 41 | ||||
| -rw-r--r-- | test/dialect/mssql/test_reflection.py | 29 |
2 files changed, 70 insertions, 0 deletions
diff --git a/test/dialect/mssql/test_compiler.py b/test/dialect/mssql/test_compiler.py index 00bbc2af4..0076c76fd 100644 --- a/test/dialect/mssql/test_compiler.py +++ b/test/dialect/mssql/test_compiler.py @@ -599,6 +599,47 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): checkpositional=("bar",), ) + @testing.variation("use_schema_translate", [True, False]) + @testing.combinations( + "abc", "has spaces", "[abc]", "[has spaces]", argnames="schemaname" + ) + def test_schema_single_token_bracketed( + self, use_schema_translate, schemaname + ): + """test for #9133. + + this is not the actual regression case for #9133, which is instead + within the reflection process. However, when we implemented + #2626, we never considered the case of ``[schema]`` without any + dots in it. + + """ + + schema_no_brackets = schemaname.strip("[]") + + if " " in schemaname: + rendered_schema = "[%s]" % (schema_no_brackets,) + else: + rendered_schema = schema_no_brackets + + metadata = MetaData() + tbl = Table( + "test", + metadata, + Column("id", Integer, primary_key=True), + schema=schemaname if not use_schema_translate else None, + ) + + self.assert_compile( + select(tbl), + "SELECT %(name)s.test.id FROM %(name)s.test" + % {"name": rendered_schema}, + schema_translate_map={None: schemaname} + if use_schema_translate + else None, + render_schema_translate=True if use_schema_translate else False, + ) + def test_schema_many_tokens_one(self): metadata = MetaData() tbl = Table( diff --git a/test/dialect/mssql/test_reflection.py b/test/dialect/mssql/test_reflection.py index 1716d68e3..59b88c6ef 100644 --- a/test/dialect/mssql/test_reflection.py +++ b/test/dialect/mssql/test_reflection.py @@ -410,6 +410,35 @@ class ReflectionTest(fixtures.TestBase, ComparesTables, AssertsCompiledSQL): ) Table(tname, MetaData(), autoload_with=conn) + @testing.combinations( + ("test_schema"), + ("[test_schema]"), + argnames="schema_value", + ) + @testing.variation( + "reflection_operation", ["has_table", "reflect_table", "get_columns"] + ) + def test_has_table_with_single_token_schema( + self, metadata, connection, schema_value, reflection_operation + ): + """test for #9133""" + tt = Table( + "test", metadata, Column("id", Integer), schema=schema_value + ) + tt.create(connection) + + if reflection_operation.has_table: + is_true(inspect(connection).has_table("test", schema=schema_value)) + elif reflection_operation.reflect_table: + m2 = MetaData() + Table("test", m2, autoload_with=connection, schema=schema_value) + elif reflection_operation.get_columns: + is_true( + inspect(connection).get_columns("test", schema=schema_value) + ) + else: + reflection_operation.fail() + def test_db_qualified_items(self, metadata, connection): Table("foo", metadata, Column("id", Integer, primary_key=True)) Table( |
