diff options
| author | Keryn Knight <keryn@kerynknight.com> | 2021-08-14 19:30:58 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-09-24 12:19:39 +0200 |
| commit | 06c50cee0fb1fd23248518334eabb2fbf61b2cbc (patch) | |
| tree | 50d028f75f66f17ea46648084bb2ecd9f077173a /django/db/models/sql/query.py | |
| parent | 7fe9b6f6df16fa875fe360a1c7d0ac53fcf08a53 (diff) | |
Fixed #33124 -- Avoided accessing the database connections when not necessary.
Follow up to bf5abf1bdcedb15e949db419c61eeec7c88414ea.
This also caches the __getitem__ access.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 8 |
1 files changed, 4 insertions, 4 deletions
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'): |
