summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-01-28 14:53:02 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-01-28 16:16:43 -0500
commit74f9d5163f4857475236bebec9ef0d65ac224886 (patch)
tree77a83f0183ffd67d1e0256b4cad87a41b5dfda9f /lib/sqlalchemy/testing
parente3fbbf830fef9bedee7b26460c79843780962bc0 (diff)
downloadsqlalchemy-74f9d5163f4857475236bebec9ef0d65ac224886.tar.gz
Render NULL for bindparam w/ None value/literal_binds, warn
Adjusted the "literal_binds" feature of :class:`_sql.Compiler` to render NULL for a bound parameter that has ``None`` as the value, either explicitly passed or omitted. The previous error message "bind parameter without a renderable value" is removed, and a missing or ``None`` value will now render NULL in all cases. Previously, rendering of NULL was starting to happen for DML statements due to internal refactorings, but was not explicitly part of test coverage, which it now is. While no error is raised, when the context is within that of a column comparison, and the operator is not "IS"/"IS NOT", a warning is emitted that this is not generally useful from a SQL perspective. Fixes: #5888 Change-Id: Id5939d8dbfb1156a9f8a7f7e76cf18327155331a
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/assertions.py3
1 files changed, 3 insertions, 0 deletions
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):