diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-12 15:48:40 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-11-12 15:48:40 -0500 |
| commit | 6397a4ff4bce537487a3b30552622544868da9a0 (patch) | |
| tree | ec7e985ee344749c47bd8a1f5e44c3851713960f /test/sql | |
| parent | 37c943233a4b01428cf4b67d766d2685309ab0e8 (diff) | |
| download | sqlalchemy-6397a4ff4bce537487a3b30552622544868da9a0.tar.gz | |
Fixed bug in type_coerce() whereby typing information
could be lost if the statement were used as a subquery
inside of another statement, as well as other similar
situations. Among other things, would cause
typing information to be lost when the Oracle/mssql dialects
would apply limit/offset wrappings. [ticket:2603]
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_selectable.py | 9 | ||||
| -rw-r--r-- | test/sql/test_types.py | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 53c9018cd..65dc65470 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -228,6 +228,15 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled "table1.col3, table1.colx FROM table1) AS anon_1" ) + def test_type_coerce_preserve_subq(self): + class MyType(TypeDecorator): + impl = Integer + + stmt = select([type_coerce(column('x'), MyType).label('foo')]) + stmt2 = stmt.select() + assert isinstance(stmt._raw_columns[0].type, MyType) + assert isinstance(stmt.c.foo.type, MyType) + assert isinstance(stmt2.c.foo.type, MyType) def test_select_on_table(self): sel = select([table1, table2], use_labels=True) diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 5f80e7947..b22969448 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -408,7 +408,7 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL): t = Table('t', metadata, Column('data', String(50))) metadata.create_all() - t.insert().values(data=type_coerce('d1BIND_OUT',MyType)).execute() + t.insert().values(data=type_coerce('d1BIND_OUT', MyType)).execute() eq_( select([type_coerce(t.c.data, MyType)]).execute().fetchall(), @@ -421,6 +421,11 @@ class UserDefinedTest(fixtures.TablesTest, AssertsCompiledSQL): ) eq_( + select([t.c.data, type_coerce(t.c.data, MyType)]).select().execute().fetchall(), + [('d1', 'd1BIND_OUT')] + ) + + eq_( select([t.c.data, type_coerce(t.c.data, MyType)]).\ where(type_coerce(t.c.data, MyType) == 'd1BIND_OUT').\ execute().fetchall(), |
