]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
handle polymorphic_discriminator in query_expression
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 18 Dec 2025 16:15:46 +0000 (11:15 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Dec 2025 19:38:18 +0000 (14:38 -0500)
commit4a8d7f2dd7101265d8bb8dc90f18126df7a16ccd
tree97de41ae522eba50f3ae006d3931dd7e5857e889
parent01dcb7a967fd91b0764e83dabaed0a8a7bfa78ec
handle polymorphic_discriminator in query_expression

Added support for using :func:`_orm.with_expression` to populate a
:func:`_orm.query_expression` attribute that is also configured as the
``polymorphic_on`` discriminator column. The ORM now detects when a query
expression column is serving as the polymorphic discriminator and updates
it to use the column provided via :func:`_orm.with_expression`, enabling
polymorphic loading to work correctly in this scenario. This allows for
patterns such as where the discriminator value is computed from a related
table.

Fixes: #12631
Change-Id: I20baf4cddc5a19664bf73764f9371b187686af68
doc/build/changelog/unreleased_21/12631.rst [new file with mode: 0644]
lib/sqlalchemy/orm/strategies.py
test/orm/inheritance/test_assorted_poly.py