From cfc9c94d97edf9aaea647bbecc89a791cf7ec0b8 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Wed, 31 May 2023 00:03:46 -0400 Subject: [PATCH] Refs #32143 -- Adjusted a comment about subquery usage in Query.split_exclude(). --- django/db/models/sql/query.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 772ba134199..12066cd4f8d 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -2035,11 +2035,10 @@ class Query(BaseExpression): ) condition.add(or_null_condition, OR) # Note that the end result will be: - # (outercol NOT IN innerq AND outercol IS NOT NULL) OR outercol IS NULL. - # This might look crazy but due to how IN works, this seems to be - # correct. If the IS NOT NULL check is removed then outercol NOT - # IN will return UNKNOWN. If the IS NULL check is removed, then if - # outercol IS NULL we will not match the row. + # NOT EXISTS (inner_q) OR outercol IS NULL + # this might look crazy but due to how NULL works, this seems to be + # correct. If the IS NULL check is removed, then if outercol + # IS NULL we will not match the row. return condition, needed_inner def set_empty(self):