diff options
| author | Iuri Diniz <iuridiniz@gmail.com> | 2016-07-29 12:54:22 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-07-29 18:44:34 -0400 |
| commit | 05f28ba2fb6b9fe1e36748bb16969afc8375a9fb (patch) | |
| tree | 8bd788bc9cfc54447b1baaf964f996bafc1801d3 /lib/sqlalchemy/orm/query.py | |
| parent | 64424b870beef2bdb5a7b97ddb5c2602277d16ac (diff) | |
| download | sqlalchemy-05f28ba2fb6b9fe1e36748bb16969afc8375a9fb.tar.gz | |
Allow None to cancel Query.group_by()
This replicates the same behavior as order_by().
order_by() will also be updated to deprecate passing
of False as this is no longer functionally different
than passing None.
Change-Id: I2fc05d0317d28b6c83373769a48f7eea32d56290
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/297
Diffstat (limited to 'lib/sqlalchemy/orm/query.py')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index c1daaaf07..c5ecbaffe 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1549,7 +1549,21 @@ class Query(object): @_generative(_no_statement_condition, _no_limit_offset) def group_by(self, *criterion): """apply one or more GROUP BY criterion to the query and return - the newly resulting :class:`.Query`""" + the newly resulting :class:`.Query` + + All existing GROUP BY settings can be suppressed by + passing ``None`` - this will suppress any GROUP BY configured + on mappers as well. + + .. versionadded:: 1.1 GROUP BY can be cancelled by passing None, + in the same way as ORDER BY. + + """ + + if len(criterion) == 1: + if criterion[0] is None: + self._group_by = False + return criterion = list(chain(*[_orm_columns(c) for c in criterion])) criterion = self._adapt_col_list(criterion) |
