Skip to content

Fixed #20024 -- Made exclude(field__in=[None, ...]) generate IS NULL clause. #19691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated the doc string to test_col_not_in_list_containing_null.
  • Loading branch information
Jkhall81 committed Aug 1, 2025
commit 42880f1a6547b76df546f9cae455532cb3a0bdce
5 changes: 2 additions & 3 deletions tests/queries/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3530,9 +3530,8 @@ def test_null_in_exclude_qs(self):

def test_col_not_in_list_containing_null(self):
"""
The following case is not handled properly because
SQL's COL NOT IN (list containing null) handling is too weird to
abstract away.
Exclude with `__in=[None]` correctly excludes NULLs and avoids
unintuitive SQL behavior like `COL NOT IN (NULL)`, which always fails.
"""
self.assertQuerySetEqual(
NullableName.objects.exclude(name__in=[None]), ["i1"], attrgetter("name")
Expand Down