summaryrefslogtreecommitdiff
path: root/test/dialect/mssql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-06-30 10:52:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-06-30 10:52:09 -0400
commitb01a415a6d2b9ef563fc085fcba93f440c686af1 (patch)
tree583399693763281af84a91afc1aa81bf760c7734 /test/dialect/mssql/test_compiler.py
parentdee57477882f8876fd97071a790fe3d3ee2164c5 (diff)
downloadsqlalchemy-b01a415a6d2b9ef563fc085fcba93f440c686af1.tar.gz
Ensure compiler uses quote_schema hook for translates renders
Fixed regression where the special dotted-schema name handling for the SQL Server dialect would not function correctly if the dotted schema name were used within the ``schema_translate_map`` feature. Fixes: #6697 Change-Id: Idb610755cbf8122e71223d5dd0a17fcb61b1b98d
Diffstat (limited to 'test/dialect/mssql/test_compiler.py')
-rw-r--r--test/dialect/mssql/test_compiler.py56
1 files changed, 44 insertions, 12 deletions
diff --git a/test/dialect/mssql/test_compiler.py b/test/dialect/mssql/test_compiler.py
index a0127fa57..2e4a08713 100644
--- a/test/dialect/mssql/test_compiler.py
+++ b/test/dialect/mssql/test_compiler.py
@@ -614,52 +614,84 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
select(tbl), "SELECT [foo.dbo].test.id FROM [foo.dbo].test"
)
- def test_force_schema_quoted_name_w_dot_case_sensitive(self):
+ @testing.combinations((True,), (False,), argnames="use_schema_translate")
+ def test_force_schema_quoted_name_w_dot_case_sensitive(
+ self, use_schema_translate
+ ):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("id", Integer, primary_key=True),
- schema=quoted_name("Foo.dbo", True),
+ schema=quoted_name("Foo.dbo", True)
+ if not use_schema_translate
+ else None,
)
self.assert_compile(
- select(tbl), "SELECT [Foo.dbo].test.id FROM [Foo.dbo].test"
+ select(tbl),
+ "SELECT [Foo.dbo].test.id FROM [Foo.dbo].test",
+ schema_translate_map={None: quoted_name("Foo.dbo", True)}
+ if use_schema_translate
+ else None,
+ render_schema_translate=True if use_schema_translate else False,
)
- def test_force_schema_quoted_w_dot_case_sensitive(self):
+ @testing.combinations((True,), (False,), argnames="use_schema_translate")
+ def test_force_schema_quoted_w_dot_case_sensitive(
+ self, use_schema_translate
+ ):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("id", Integer, primary_key=True),
- schema="[Foo.dbo]",
+ schema="[Foo.dbo]" if not use_schema_translate else None,
)
self.assert_compile(
- select(tbl), "SELECT [Foo.dbo].test.id FROM [Foo.dbo].test"
+ select(tbl),
+ "SELECT [Foo.dbo].test.id FROM [Foo.dbo].test",
+ schema_translate_map={None: "[Foo.dbo]"}
+ if use_schema_translate
+ else None,
+ render_schema_translate=True if use_schema_translate else False,
)
- def test_schema_autosplit_w_dot_case_insensitive(self):
+ @testing.combinations((True,), (False,), argnames="use_schema_translate")
+ def test_schema_autosplit_w_dot_case_insensitive(
+ self, use_schema_translate
+ ):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("id", Integer, primary_key=True),
- schema="foo.dbo",
+ schema="foo.dbo" if not use_schema_translate else None,
)
self.assert_compile(
- select(tbl), "SELECT foo.dbo.test.id FROM foo.dbo.test"
+ select(tbl),
+ "SELECT foo.dbo.test.id FROM foo.dbo.test",
+ schema_translate_map={None: "foo.dbo"}
+ if use_schema_translate
+ else None,
+ render_schema_translate=True if use_schema_translate else False,
)
- def test_schema_autosplit_w_dot_case_sensitive(self):
+ @testing.combinations((True,), (False,), argnames="use_schema_translate")
+ def test_schema_autosplit_w_dot_case_sensitive(self, use_schema_translate):
metadata = MetaData()
tbl = Table(
"test",
metadata,
Column("id", Integer, primary_key=True),
- schema="Foo.dbo",
+ schema="Foo.dbo" if not use_schema_translate else None,
)
self.assert_compile(
- select(tbl), "SELECT [Foo].dbo.test.id FROM [Foo].dbo.test"
+ select(tbl),
+ "SELECT [Foo].dbo.test.id FROM [Foo].dbo.test",
+ schema_translate_map={None: "Foo.dbo"}
+ if use_schema_translate
+ else None,
+ render_schema_translate=True if use_schema_translate else False,
)
def test_delete_schema(self):