diff options
author | Simon Charette <charettes@users.noreply.github.com> | 2019-10-31 09:55:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-31 09:55:10 -0400 |
commit | 1abe3aed1764141561ed57dc6d5070845615ada5 (patch) | |
tree | ed03a18d065569dabb6e74acd250620db0aa16fd | |
parent | 3cf907c20c4f4d94f649fbb93a006af5c61b30b8 (diff) | |
download | django-remove-unnecesary-if-wrap.tar.gz |
Refs #13312 -- Removed unnecessary IF wrapping in MySQL nulls_last handling.remove-unnecesary-if-wrap
The MySQL `ISNULL` function already returns 0 and 1 booleans.
-rw-r--r-- | django/db/models/expressions.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py index 2eae16541e..44a52c1dc9 100644 --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -1156,7 +1156,7 @@ class OrderBy(BaseExpression): def as_mysql(self, compiler, connection): template = None if self.nulls_last: - template = 'IF(ISNULL(%(expression)s),1,0), %(expression)s %(ordering)s ' + template = 'ISNULL(%(expression)s), %(expression)s %(ordering)s ' elif self.nulls_first: template = 'IF(ISNULL(%(expression)s),0,1), %(expression)s %(ordering)s ' return self.as_sql(compiler, connection, template=template) |