diff options
author | Дилян Палаузов <Dilyan.Palauzov@db.com> | 2018-01-12 09:05:16 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-01-12 12:44:50 -0500 |
commit | a38ae914d89809aed6d79337b74a8b31b6d3849a (patch) | |
tree | 42a8465e37fc02b70d8d3f876d23947acb1a2455 /django/db/models/sql/compiler.py | |
parent | 4bcec02368b7e5466f64dc17286689b16613c94b (diff) | |
download | django-a38ae914d89809aed6d79337b74a8b31b6d3849a.tar.gz |
Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements.
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r-- | django/db/models/sql/compiler.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index a65c6e2596..3080b8c3ee 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -114,13 +114,10 @@ class SQLCompiler: for col in cols: expressions.append(col) for expr, (sql, params, is_ref) in order_by: - if expr.contains_aggregate: - continue - # We can skip References to select clause, as all expressions in - # the select clause are already part of the group by. - if is_ref: - continue - expressions.extend(expr.get_source_expressions()) + # Skip References to the select clause, as all expressions in the + # select clause are already part of the group by. + if not expr.contains_aggregate and not is_ref: + expressions.extend(expr.get_source_expressions()) having_group_by = self.having.get_group_by_cols() if self.having else () for expr in having_group_by: expressions.append(expr) @@ -283,7 +280,7 @@ class SQLCompiler: continue col, order = get_order_dir(field, asc) - descending = True if order == 'DESC' else False + descending = order == 'DESC' if col in self.query.annotation_select: # Reference to expression in SELECT clause @@ -646,7 +643,7 @@ class SQLCompiler: The 'name' is of the form 'field1__field2__...__fieldN'. """ name, order = get_order_dir(name, default_order) - descending = True if order == 'DESC' else False + descending = order == 'DESC' pieces = name.split(LOOKUP_SEP) field, targets, alias, joins, path, opts = self._setup_joins(pieces, opts, alias) @@ -747,11 +744,9 @@ class SQLCompiler: # included in the related selection. fields_found = set() if requested is None: - if isinstance(self.query.select_related, dict): + restricted = isinstance(self.query.select_related, dict) + if restricted: requested = self.query.select_related - restricted = True - else: - restricted = False def get_related_klass_infos(klass_info, related_klass_infos): klass_info['related_klass_infos'] = related_klass_infos |