diff options
| author | Diana Clarke <diana.joan.clarke@gmail.com> | 2013-03-29 14:58:33 -0400 |
|---|---|---|
| committer | Diana Clarke <diana.joan.clarke@gmail.com> | 2013-03-29 14:58:33 -0400 |
| commit | 423cd7fbf695d2becdfc83751a8dbc0650854bea (patch) | |
| tree | cf856a236a34971a2227f2d0da723c41dc5b6606 /test/orm/test_query.py | |
| parent | 7dff6f6d490528f5e88493cdf4b14d3136b40d3c (diff) | |
| download | sqlalchemy-423cd7fbf695d2becdfc83751a8dbc0650854bea.tar.gz | |
adding convenience method exists() to Query (see # 2673)
Diffstat (limited to 'test/orm/test_query.py')
| -rw-r--r-- | test/orm/test_query.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/orm/test_query.py b/test/orm/test_query.py index ac9c95f41..3882ec4b5 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -1620,6 +1620,21 @@ class AggregateTest(QueryTest): assert [User(name=u'jack',id=7), User(name=u'fred',id=9)] == sess.query(User).order_by(User.id).group_by(User).join('addresses').having(func.count(Address.id)< 2).all() + +class ExistsTest(QueryTest, AssertsCompiledSQL): + + def test_exists(self): + User = self.classes.User + sess = create_session() + q1 = sess.query(User).filter(User.name == 'fred') + self.assert_compile(sess.query(q1.exists()), + 'SELECT EXISTS (' + 'SELECT 1 FROM users WHERE users.name = :name_1' + ') AS anon_1', + dialect=default.DefaultDialect() + ) + + class CountTest(QueryTest): def test_basic(self): users, User = self.tables.users, self.classes.User |
