]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
ensure explicit left side considered for ON clause in join_from
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 21 Oct 2025 12:48:12 +0000 (08:48 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 21 Oct 2025 13:21:29 +0000 (09:21 -0400)
commit602355753964179a0af8e6e2879491ff2edbad1e
treef179a1a2498621d20aec4c8509698896d795735a
parent893a4f2f3566978ad2b2b352a5cb928bdcfe22d4
ensure explicit left side considered for ON clause in join_from

Fixed an issue in :meth:`_sql.Select.join_from` where the join condition
between the left and right tables specified in the method call could be
incorrectly determined based on an intermediate table already present in
the FROM clause, rather than matching the foreign keys between the
immediate left and right arguments. The join condition is now determined by
matching primary keys between the two tables explicitly passed to
:meth:`_sql.Select.join_from`, ensuring consistent and predictable join
behavior regardless of the order of join operations or other tables present
in the query.  The fix is applied to both the Core and ORM implementations
of :meth:`_sql.Select.join_from`.

Fixes: #12931
Change-Id: Id457d441ee8a1bd64a002e57a9dcfd6fc56ff15e
doc/build/changelog/unreleased_21/12931.rst [new file with mode: 0644]
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/sql/selectable.py
test/orm/test_core_compilation.py
test/sql/test_select.py