diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 14 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/assertions.py | 3 |
2 files changed, 13 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: diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index f2ed91b79..79125e1f1 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -388,6 +388,7 @@ class AssertsCompiledSQL(object): check_prefetch=None, use_default_dialect=False, allow_dialect_select=False, + supports_default_values=True, literal_binds=False, render_postcompile=False, schema_translate_map=None, @@ -396,6 +397,7 @@ class AssertsCompiledSQL(object): ): if use_default_dialect: dialect = default.DefaultDialect() + dialect.supports_default_values = supports_default_values elif allow_dialect_select: dialect = None else: @@ -406,6 +408,7 @@ class AssertsCompiledSQL(object): dialect = config.db.dialect elif dialect == "default": dialect = default.DefaultDialect() + dialect.supports_default_values = supports_default_values elif dialect == "default_enhanced": dialect = default.StrCompileDialect() elif isinstance(dialect, util.string_types): |
