From: Federico Caselli Date: Wed, 5 May 2021 20:06:19 +0000 (+0200) Subject: Add a comment in the compiler on why the NOT IN operator X-Git-Tag: rel_1_4_14~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=adb3a302ef1f25ae41b2a83ce857e3ed2613c84d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add a comment in the compiler on why the NOT IN operator is rendered using brackets. Change-Id: I39c2e6a03e8aad7ff27bc6000da5bc9f1de14dc2 --- diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 437a11a607..dedd75f5cb 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -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 )