From: Mike Bayer Date: Thu, 3 Apr 2008 13:12:42 +0000 (+0000) Subject: - Added some convenience descriptors to Query: X-Git-Tag: rel_0_4_5~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f899d7900509cbfdffdf8c48a93e908ed2249b77;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Added some convenience descriptors to Query: query.statement returns the full SELECT construct, query.whereclause returns just the WHERE part of the SELECT construct. --- diff --git a/CHANGES b/CHANGES index 70ca76c307..2f30c883cf 100644 --- a/CHANGES +++ b/CHANGES @@ -105,6 +105,11 @@ CHANGES - query.order_by() and query.group_by() will accept multiple arguments using *args (like select() already does). + - Added some convenience descriptors to Query: + query.statement returns the full SELECT construct, + query.whereclause returns just the WHERE part of the + SELECT construct. + - Fixed/covered case when using a False/0 value as a polymorphic discriminator. diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 9751cc9ba2..a2312e3633 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -161,6 +161,16 @@ class Query(object): return self._session session = property(session) + def statement(self): + """return the full SELECT statement represented by this Query.""" + return self._compile_context().statement + statement = property(statement) + + def whereclause(self): + """return the WHERE criterion for this Query.""" + return self._criterion + whereclause = property(whereclause) + def _with_current_path(self, path): q = self._clone() q._current_path = path