diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-23 14:54:26 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-23 14:54:26 -0400 |
commit | 0a556d322029651be9018a1b41f13e23edf18388 (patch) | |
tree | 81190d8213cfdeff3857a47449c4373d1559823b /test/sql/test_generative.py | |
parent | 4475506371342b6e61d8dc236ec1ba9d7877e9e5 (diff) | |
download | sqlalchemy-0a556d322029651be9018a1b41f13e23edf18388.tar.gz |
- Fixed bug in Query whereby the usage of aliased() constructs
would fail if the underlying table (but not the actual alias)
were referenced inside the subquery generated by
q.from_self() or q.select_from().
Diffstat (limited to 'test/sql/test_generative.py')
-rw-r--r-- | test/sql/test_generative.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py index a6f8c5956..5457c7a79 100644 --- a/test/sql/test_generative.py +++ b/test/sql/test_generative.py @@ -207,6 +207,31 @@ class ClauseTest(TestBase, AssertsCompiledSQL): assert c1 == str(clause) assert str(clause2) == str(t1.join(t2, t1.c.col2==t2.c.col3)) + def test_aliased_column_adapt(self): + clause = t1.select() + + aliased = t1.select().alias() + aliased2 = t1.alias() + + adapter = sql_util.ColumnAdapter(aliased) + + f = select([ + adapter.columns[c] + for c in aliased2.c + ]).select_from(aliased) + + s = select([aliased2]).select_from(aliased) + eq_(str(s), str(f)) + + f = select([ + adapter.columns[func.count(aliased2.c.col1)] + ]).select_from(aliased) + eq_( + str(select([func.count(aliased2.c.col1)]).select_from(aliased)), + str(f) + ) + + def test_text(self): clause = text("select * from table where foo=:bar", bindparams=[bindparam('bar')]) c1 = str(clause) |