diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2016-07-29 19:03:38 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@ln3.zzzcomputing.com> | 2016-07-29 19:03:38 -0400 |
| commit | 5df226c2ab549ccf84f912110bf233f562d5eb32 (patch) | |
| tree | 9a997c0d6fe1ac8acfc586015f911f70e08cbdb9 /lib/sqlalchemy | |
| parent | 9130e5923ee88802d06bd5fb2db168198eed2f8c (diff) | |
| parent | 05f28ba2fb6b9fe1e36748bb16969afc8375a9fb (diff) | |
| download | sqlalchemy-5df226c2ab549ccf84f912110bf233f562d5eb32.tar.gz | |
Merge "Allow None to cancel Query.group_by()"
Diffstat (limited to 'lib/sqlalchemy')
| -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) |
