]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Fix type of CASE expressions which include NULLs
authorDavid Evans <dave@evansd.net>
Mon, 15 Jan 2024 15:13:53 +0000 (10:13 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 15 Jan 2024 17:08:20 +0000 (12:08 -0500)
commit0f5144597501bf846b966af37d620616fc045a7b
tree65ca32f3da3f90e7f2e3617182920021dda83a2d
parenta25abbbeb0933d47b61b2614e578cf06b5cb78a1
Fix type of CASE expressions which include NULLs

Fixed issues in :func:`_sql.case` where the logic for determining the
type of the expression could result in :class:`.NullType` if the last
element in the "whens" had no type, or in other cases where the type
could resolve to ``None``.  The logic has been updated to scan all
given expressions so that the first non-null type is used, as well as
to always ensure a type is present.  Pull request courtesy David Evans.

updates to test suite to use modern fixture patterns by Mike

Fixes: #10843
Closes: #10847
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10847
Pull-request-sha: 4fd5c39ab56de046e68c08f6c20cd1f7b2cb0e0d

Change-Id: I40f905ac336a8a42b617ff9473dbd9c22ac57505
(cherry picked from commit 8f4ac0c0f07509d2f8a4bce9cbb07ac08ad04044)
doc/build/changelog/unreleased_20/10843.rst [new file with mode: 0644]
lib/sqlalchemy/sql/elements.py
test/sql/test_case_statement.py