diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/postgresql/operations.py | 8 | ||||
| -rw-r--r-- | django/db/models/lookups.py | 12 |
2 files changed, 8 insertions, 12 deletions
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 93eb982f4b..4a42126e81 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -154,14 +154,6 @@ class DatabaseOperations(BaseDatabaseOperations): def lookup_cast(self, lookup_type, internal_type=None): lookup = "%s" - - if lookup_type == "isnull" and internal_type in ( - "CharField", - "EmailField", - "TextField", - ): - return "%s::text" - # Cast text lookups to text to allow things like filter(x__contains=4) if lookup_type in ( "iexact", diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py index 896d3eee44..a562a3db38 100644 --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -624,11 +624,15 @@ class IsNull(BuiltinLookup): raise ValueError( "The QuerySet value for an isnull lookup must be True or False." ) - if isinstance(self.lhs, Value) and self.lhs.value is None: - if self.rhs: - raise FullResultSet + if isinstance(self.lhs, Value): + if self.lhs.value is None or ( + self.lhs.value == "" + and connection.features.interprets_empty_strings_as_nulls + ): + result_exception = FullResultSet if self.rhs else EmptyResultSet else: - raise EmptyResultSet + result_exception = EmptyResultSet if self.rhs else FullResultSet + raise result_exception sql, params = self.process_lhs(compiler, connection) if self.rhs: return "%s IS NULL" % sql, params |
