From 06c50cee0fb1fd23248518334eabb2fbf61b2cbc Mon Sep 17 00:00:00 2001 From: Keryn Knight Date: Sat, 14 Aug 2021 19:30:58 +0100 Subject: Fixed #33124 -- Avoided accessing the database connections when not necessary. Follow up to bf5abf1bdcedb15e949db419c61eeec7c88414ea. This also caches the __getitem__ access. --- django/db/models/sql/query.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 388c60545f..e9fa0d7547 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -2332,10 +2332,10 @@ class Query(BaseExpression): # 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. - return ( - connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and - field.empty_strings_allowed - ) or field.null + return field.null or ( + field.empty_strings_allowed and + connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls + ) def get_order_dir(field, default='ASC'): -- cgit v1.3