schema_translate_map is running on aliases
Issue #3924
resolved
Not sure how nobody noticed this, guess the feature hasn't seen any real use yet:
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index e7504a7..a3311f8 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -3406,6 +3406,26 @@ class SchemaTest(fixtures.TestBase, AssertsCompiledSQL):
schema_translate_map=schema_translate_map
)
+ def test_schema_translate_aliases(self):
+ schema_translate_map = {None: 'bar'}
+
+ alias = table1.alias()
+
+ stmt = select([
+ table2, alias
+ ]).select_from(table2.join(alias, table2.c.otherid == alias.c.myid)).\
+ where(alias.c.name == 'foo')
+
+ self.assert_compile(
+ stmt,
+ "SELECT bar.myothertable.otherid, bar.myothertable.othername, "
+ "mytable_1.myid, mytable_1.name, mytable_1.description "
+ "FROM bar.myothertable JOIN bar.mytable AS mytable_1 "
+ "ON bar.myothertable.otherid = mytable_1.myid "
+ "WHERE mytable_1.name = :name_1",
+ schema_translate_map=schema_translate_map
+ )
+
def test_schema_translate_crud(self):
schema_translate_map = {"remote_owner": "foob", None: 'bar'}
Comments (2)
-
reporter -
reporter - changed status to resolved
Only use schema_translate_map on SchemaItem subclasses
Fixed bug in new "schema translate" feature where the translated schema name would be invoked in terms of an alias name when rendered along with a column expression; occurred only when the source translate name was "None". The "schema translate" feature now only takes effect for :class:
.SchemaItem
and :class:.SchemaType
subclasses, that is, objects that correspond to a DDL-creatable structure in a database.Change-Id: Ie8cb35aeaba2c67efec8c8c57c219e4dd346e44a Fixes:
#3924→ <<cset b4e880534e1e>>
- Log in to comment
https://gerrit.sqlalchemy.org/323