summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-11-08 18:29:16 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-11-09 15:30:58 -0500
commitb919a0a85afd5066f9188b20ef06ee1b4af884a9 (patch)
tree39536ce18d644aae3488905ba501aeffcee8337b /lib/sqlalchemy/testing/suite/test_reflection.py
parentcf404d840c15fe167518dd884b295dc99ee26178 (diff)
downloadsqlalchemy-b919a0a85afd5066f9188b20ef06ee1b4af884a9.tar.gz
change the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql quoting
Adjusted the compiler's generation of "post compile" symbols including those used for "expanding IN" as well as for the "schema translate map" to not be based directly on plain bracketed strings with underscores, as this conflicts directly with SQL Server's quoting format of also using brackets, which produces false matches when the compiler replaces "post compile" and "schema translate" symbols. The issue created easy to reproduce examples both with the :meth:`.Inspector.get_schema_names` method when used in conjunction with the :paramref:`_engine.Connection.execution_options.schema_translate_map` feature, as well in the unlikely case that a symbol overlapping with the internal name "POSTCOMPILE" would be used with a feature like "expanding in". Fixes: #7300 Change-Id: I6255c850b140522a4aba95085216d0bca18ce230
Diffstat (limited to 'lib/sqlalchemy/testing/suite/test_reflection.py')
-rw-r--r--lib/sqlalchemy/testing/suite/test_reflection.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py
index 6fbd74689..ba176bcd9 100644
--- a/lib/sqlalchemy/testing/suite/test_reflection.py
+++ b/lib/sqlalchemy/testing/suite/test_reflection.py
@@ -2,7 +2,6 @@ import operator
import re
import sqlalchemy as sa
-from sqlalchemy import func
from .. import config
from .. import engines
from .. import eq_
@@ -15,6 +14,7 @@ from ..schema import Column
from ..schema import Table
from ... import event
from ... import ForeignKey
+from ... import func
from ... import Identity
from ... import inspect
from ... import Integer
@@ -25,6 +25,7 @@ from ... import types as sql_types
from ...schema import DDL
from ...schema import Index
from ...sql.elements import quoted_name
+from ...sql.schema import BLANK_SCHEMA
from ...testing import is_false
from ...testing import is_true
@@ -539,6 +540,20 @@ class ComponentReflectionTest(fixtures.TablesTest):
self.assert_(testing.config.test_schema in insp.get_schema_names())
@testing.requires.schema_reflection
+ def test_get_schema_names_w_translate_map(self, connection):
+ """test #7300"""
+
+ connection = connection.execution_options(
+ schema_translate_map={
+ "foo": "bar",
+ BLANK_SCHEMA: testing.config.test_schema,
+ }
+ )
+ insp = inspect(connection)
+
+ self.assert_(testing.config.test_schema in insp.get_schema_names())
+
+ @testing.requires.schema_reflection
def test_dialect_initialize(self):
engine = engines.testing_engine()
inspect(engine)