[Sqlalchemy-tickets] Issue #3924: schema_translate_map is running on aliases (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2017-02-28 18:03:51
|
New issue 3924: schema_translate_map is running on aliases https://bitbucket.org/zzzeek/sqlalchemy/issues/3924/schema_translate_map-is-running-on-aliases Michael Bayer: Not sure how nobody noticed this, guess the feature hasn't seen any real use yet: ``` #!diff 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'} ``` |