summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-01-28 22:19:10 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2021-01-28 22:19:10 +0000
commitbead576769e655481cddb4623fad4bfa0aaccdda (patch)
treebbc36ff33dcc2c4d1a36e63c47f5d13be04eb336 /lib/sqlalchemy/sql/compiler.py
parent03179a96bfb9dd7ce17274fed44908c25229dedf (diff)
parent74f9d5163f4857475236bebec9ef0d65ac224886 (diff)
downloadsqlalchemy-bead576769e655481cddb4623fad4bfa0aaccdda.tar.gz
Merge "Render NULL for bindparam w/ None value/literal_binds, warn"
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index aabc257eb..353de2c48 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -2055,6 +2055,7 @@ class SQLCompiler(Compiled):
_in_binary = kw.get("_in_binary", False)
kw["_in_binary"] = True
+ kw["_binary_op"] = binary.operator
text = (
binary.left._compiler_dispatch(
self, eager_grouping=eager_grouping, **kw
@@ -2306,10 +2307,15 @@ class SQLCompiler(Compiled):
value = render_literal_value
else:
if bindparam.value is None and bindparam.callable is None:
- raise exc.CompileError(
- "Bind parameter '%s' without a "
- "renderable value not allowed here." % bindparam.key
- )
+ op = kw.get("_binary_op", None)
+ if op and op not in (operators.is_, operators.is_not):
+ util.warn_limited(
+ "Bound parameter '%s' rendering literal NULL in a SQL "
+ "expression; comparisons to NULL should not use "
+ "operators outside of 'is' or 'is not'",
+ (bindparam.key,),
+ )
+ return self.process(sqltypes.NULLTYPE, **kw)
value = bindparam.effective_value
if bindparam.expanding: