]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Render NULL for bindparam w/ None value/literal_binds, warn
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Jan 2021 19:53:02 +0000 (14:53 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Jan 2021 21:16:43 +0000 (16:16 -0500)
commit74f9d5163f4857475236bebec9ef0d65ac224886
tree77a83f0183ffd67d1e0256b4cad87a41b5dfda9f
parente3fbbf830fef9bedee7b26460c79843780962bc0
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
doc/build/changelog/unreleased_14/5888.rst [new file with mode: 0644]
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/testing/assertions.py
test/sql/test_compiler.py
test/sql/test_insert.py