diff options
| author | Дилян Палаузов <Dilyan.Palauzov@db.com> | 2018-01-03 18:52:12 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-03 20:12:23 -0500 |
| commit | d7b2aa24f75434c2ce50100cfef3586071e0747a (patch) | |
| tree | 9074eb7522888e744f948c52174f367a4281c200 /django/db/models/sql/query.py | |
| parent | c2d0f8c084456b5073252a91eeb09ab3d7453b18 (diff) | |
Fixed #28982 -- Simplified code with and/or.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index bfee2256e6..e657594c86 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -805,9 +805,9 @@ class Query: if isinstance(self.group_by, tuple): self.group_by = tuple([col.relabeled_clone(change_map) for col in self.group_by]) self.select = tuple([col.relabeled_clone(change_map) for col in self.select]) - if self._annotations: - self._annotations = OrderedDict( - (key, col.relabeled_clone(change_map)) for key, col in self._annotations.items()) + self._annotations = self._annotations and OrderedDict( + (key, col.relabeled_clone(change_map)) for key, col in self._annotations.items() + ) # 2. Rename the alias in the internal table/alias datastructures. for old_alias, new_alias in change_map.items(): @@ -1061,9 +1061,7 @@ class Query: and get_transform(). """ # __exact is the default lookup if one isn't given. - if not lookups: - lookups = ['exact'] - + lookups = lookups or ['exact'] for name in lookups[:-1]: lhs = self.try_transform(lhs, name) # First try get_lookup() so that the lookup takes precedence if the lhs @@ -2050,10 +2048,10 @@ class Query: # used. The proper fix would be to defer all decisions where # is_nullable() is needed to the compiler stage, but that is not easy # to do currently. - if connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and field.empty_strings_allowed: - return True - else: - return field.null + return ( + connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and + field.empty_strings_allowed + ) or field.null def get_order_dir(field, default='ASC'): |
