]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add a comment in the compiler on why the NOT IN operator
authorFederico Caselli <cfederico87@gmail.com>
Wed, 5 May 2021 20:06:19 +0000 (22:06 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Wed, 5 May 2021 20:06:19 +0000 (22:06 +0200)
is rendered using brackets.

Change-Id: I39c2e6a03e8aad7ff27bc6000da5bc9f1de14dc2

lib/sqlalchemy/sql/compiler.py

index 437a11a6077b87f0bf23b369a5c6d4bc6bfc0cc4..dedd75f5cbe33c3969a17c1c6d8fb69d0a61cf5c 100644 (file)
@@ -1908,6 +1908,9 @@ class SQLCompiler(Compiled):
         return self._render_in_expr_w_bindparam(binary, operator, **kw)
 
     def visit_not_in_op_binary(self, binary, operator, **kw):
+        # The brackets are required in the NOT IN operation because the empty
+        # case is handled using the form "(col NOT IN (null) OR 1 = 1)".
+        # The presence of the OR makes the brackets required.
         return "(%s)" % self._render_in_expr_w_bindparam(
             binary, operator, **kw
         )