summaryrefslogtreecommitdiff
path: root/test/orm/test_query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-02 11:06:08 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-02 11:06:08 -0500
commit29de1077b35fb264f4b1727bd1f4987644ff52b7 (patch)
treebe0c3283a6447f316fcf44b6c1945bead922ec89 /test/orm/test_query.py
parent5b0919f3f5c7678c587858a47e38acd4a5b82f25 (diff)
downloadsqlalchemy-29de1077b35fb264f4b1727bd1f4987644ff52b7.tar.gz
- Fixed bug in new :class:`.TextAsFrom` construct where :class:`.Column`-
oriented row lookups were not matching up to the ad-hoc :class:`.ColumnClause` objects that :class:`.TextAsFrom` generates, thereby making it not usable as a target in :meth:`.Query.from_statement`. Also fixed :meth:`.Query.from_statement` mechanics to not mistake a :class:`.TextAsFrom` for a :class:`.Select` construct. This bug is also an 0.9 regression as the :meth:`.Text.columns` method is called to accommodate the :paramref:`.text.typemap` argument. [ticket:2932]
Diffstat (limited to 'test/orm/test_query.py')
-rw-r--r--test/orm/test_query.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/test/orm/test_query.py b/test/orm/test_query.py
index 64b8cfdc4..07cb24cb6 100644
--- a/test/orm/test_query.py
+++ b/test/orm/test_query.py
@@ -1,7 +1,7 @@
from sqlalchemy.sql import operators
from sqlalchemy import MetaData, null, exists, text, union, literal, \
literal_column, func, between, Unicode, desc, and_, bindparam, \
- select, distinct, or_, collate, insert
+ select, distinct, or_, collate, insert, Integer, String
from sqlalchemy import inspect
from sqlalchemy import exc as sa_exc, util
from sqlalchemy.sql import compiler, table, column
@@ -2080,6 +2080,43 @@ class TextTest(QueryTest):
[User(id=7), User(id=8), User(id=9), User(id=10)]
)
+ def test_via_textasfrom_from_statement(self):
+ User = self.classes.User
+ s = create_session()
+
+ eq_(
+ s.query(User).from_statement(
+ text("select * from users order by id").\
+ columns(id=Integer, name=String)
+ ).all(),
+ [User(id=7), User(id=8), User(id=9), User(id=10)]
+ )
+
+ def test_via_textasfrom_select_from(self):
+ User = self.classes.User
+ s = create_session()
+
+ eq_(
+ s.query(User).select_from(
+ text("select * from users order by id").\
+ columns(id=Integer, name=String)
+ ).all(),
+ [User(id=7), User(id=8), User(id=9), User(id=10)]
+ )
+
+ def test_via_textasfrom_use_mapped_columns(self):
+ User = self.classes.User
+ s = create_session()
+
+ eq_(
+ s.query(User).select_from(
+ text("select * from users order by id").\
+ columns(User.id, User.name)
+ ).all(),
+ [User(id=7), User(id=8), User(id=9), User(id=10)]
+ )
+
+
class ParentTest(QueryTest, AssertsCompiledSQL):
__dialect__ = 'default'