]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
accommodate for "clone" of ColumnClause
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 21 Dec 2021 23:08:33 +0000 (18:08 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 22 Dec 2021 01:11:35 +0000 (20:11 -0500)
commita0cfc934dc1286f24f3e769b305cf2faaa818302
treedaefcfc38bc866e726bad5531d1dc05f272e9716
parent52ae2230d46414b6c270b9c83c6004ab15fe01d9
accommodate for "clone" of ColumnClause

for use with the ClauseElement.params() method,
altered ColumnClause._clone() so that while the element
stays immutable, if the column is associated with a subquery,
it returns a new version of itself as corresponding to a
clone of the subquery.  this allows processing functions
to access the parameters in the subquery and produce a
copy of it.  The use case here is the expanded use of
.params() within loader strategies that use
HasCacheKey._apply_params_to_element().

Fixed issue in new "loader criteria" method
:meth:`_orm.PropComparator.and_` where usage with a loader strategy like
:func:`_orm.selectinload` against a column that was a member of the ``.c.``
collection of a subquery object, where the subquery would be dynamically
added to the FROM clause of the statement, would be subject to stale
parameter values within the subquery in the SQL statement cache, as the
process used by the loader strategy to replace the parameters at execution
time would fail to accommodate the subquery when received in this form.

Fixes: #7489
Change-Id: Ibb3b6af140b8a62a2c8d05b2ac92e86ca3013c46
(cherry picked from commit 267e9cbf6e3c165a4e953b49d979d7f4ddc533f9)
doc/build/changelog/unreleased_14/7489.rst [new file with mode: 0644]
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/traversals.py
lib/sqlalchemy/sql/visitors.py
test/orm/test_relationship_criteria.py
test/sql/test_external_traversal.py