summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-03-22 19:55:00 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-03-22 19:55:00 -0400
commit39a8e2ed375ed66c67a6fe24805ae0503f296e07 (patch)
tree2f4922e754f3dcc5f8fa628044ed6257eedc344b /lib
parentb00e15b50f83b4d939a15162fe53863bc15be4f0 (diff)
downloadsqlalchemy-39a8e2ed375ed66c67a6fe24805ae0503f296e07.tar.gz
- Fixed regression from 0.8.3 as a result of :ticket:`2818`
where :meth:`.Query.exists` wouldn't work on a query that only had a :meth:`.Query.select_from` entry but no other entities. re: #2818 fixes #2995
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/query.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 0f5b8bf88..afcbf3500 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -2543,7 +2543,14 @@ class Query(object):
.. versionadded:: 0.8.1
"""
- return sql.exists(self.with_labels().statement.with_only_columns(['1']))
+
+ # .add_columns() for the case that we are a query().select_from(X),
+ # so that ".statement" can be produced (#2995) but also without
+ # omitting the FROM clause from a query(X) (#2818);
+ # .with_only_columns() after we have a core select() so that
+ # we get just "SELECT 1" without any entities.
+ return sql.exists(self.add_columns('1').with_labels().
+ statement.with_only_columns(['1']))
def count(self):
"""Return a count of rows this Query would return.