]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
remove upfront sanitization of entities from joins
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 2 Sep 2025 16:26:06 +0000 (12:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Sep 2025 13:10:03 +0000 (09:10 -0400)
commite263825e3c5060bf4f47eed0e833c6660a31658e
treeada9bb9a352351413edb4e5c970528a3c3eee6ff
parent2b2f8b424410d11c3e6d2af505ec8ff1dfe1432e
remove upfront sanitization of entities from joins

ORM entities can now be involved within the SQL expressions used within
:paramref:`_orm.relationship.primaryjoin` and
:paramref:`_orm.relationship.secondaryjoin` parameters without the ORM
entity information being implicitly sanitized, allowing ORM-specific
features such as single-inheritance criteria in subqueries to continue
working even when used in this context.   This is made possible by overall
ORM simplifications that occurred as of the 2.0 series.  The changes here
also provide a performance boost (up to 20%) for certain query compilation
scenarios.

Here we see that we're not only able to remove the
relationships deannotation steps, but we can also change
context -> _get_current_adapter() to be an unconditional
adapter, since the only remaining case where it was conditional
was the polymorphic_adapter.  that adapter is itself
only used for exotic joined inh cases against select
statements (totally not used by anyone) or by abstract
concrete setups.   That lets us remove a whole host
of orm_annotate stuff that doesn't apply anymore.

if this does lead to user regressions in 2.1 it will be
a good reason for us to revisit the complexity here in
any case.

Fixes: #12843
Change-Id: Ic1c6e72d70ec6a27b73495c1a56e9307c9280133
doc/build/changelog/unreleased_21/12843.rst [new file with mode: 0644]
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/util.py
test/orm/inheritance/test_relationship.py
test/orm/test_relationships.py
test/profiles.txt