summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-11-12 15:48:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-11-12 15:48:40 -0500
commit6397a4ff4bce537487a3b30552622544868da9a0 (patch)
treeec7e985ee344749c47bd8a1f5e44c3851713960f /test/sql
parent37c943233a4b01428cf4b67d766d2685309ab0e8 (diff)
downloadsqlalchemy-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.py9
-rw-r--r--test/sql/test_types.py7
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(),