2.0.58
Released: November 16, 2026
orm
-
[orm] [bug] Fixed issue where deleting the parent object of a one-to-many relationship configured with
_orm.relationship.post_update, such as the one-to-many side of a bidirectionalpost_updaterelationship, would emit the UPDATE that sets the foreign key of the remaining related objects to NULL twice: once within the regular UPDATE for those objects and again as the post-update. Only the post-update UPDATE is now emitted, and it is explicitly ordered to run before the DELETE of the parent row. Fix approach courtesy 18Abhinav07, with thanks to canblmz1 for the initial analysis.References: #10936
-
[orm] [bug] Fixed issue where criteria applied to a relationship using
PropComparator.and_()within_orm.selectinload()or_orm.lazyload(), where the criteria referred to an_orm.aliased()construct against a subquery that's also the parent entity of the loader option, would load the related collection using the bound parameter values within that subquery from the first execution of the statement, once the statement was retrieved from the compiled cache.References: #13766
-
[orm] [bug] Fixed issue where loader options nested beneath a
_orm.selectin_polymorphic()option, such as a_orm.selectinload()for a subclass-specific relationship, would be silently skipped when the enclosing relationship load was against an aliased entity such as one produced by_orm.with_polymorphic(), and a structurally different parent statement using the same loader options had been executed and cached previously. The selectin polymorphic loader now uses options from the cached statement in the same way as the selectin relationship loader already does.References: #13777
-
[orm] [bug] Fixed issue where loader options nested beneath a
_orm.subqueryload()option against an aliased entity, such assubqueryload(A.bs.of_type(aliased(B))), would be silently skipped when the statement was served from the compiled cache and was constructed using a new_orm.aliased()or_orm.with_polymorphic()object, as is typical when the statement is built within a function. Nested options such as_orm.load_only(),_orm.undefer()and_orm.selectinload()took effect only the first time the statement was run. The subquery loader now uses options from the cached statement in the same way as the selectin relationship loader.References: #13779
-
[orm] [bug] Fixed issue where a subclass configured with
_orm.Mapper.polymorphic_loadset to"selectin"would cause a statement to raiseArgumentErrorwhen the statement selected from an_orm.aliased()or_orm.with_polymorphic()construct against the base class, or included another entity, along with loader options such as_orm.undefer()or_orm.selectinload()against that construct or entity. The automatic load of the subclass now leaves out loader options that refer to other entities, which were already applied by the enclosing statement.References: #13780
-
[orm] [bug] Fixed issue where joined eager loading that wraps the statement in a subquery, as occurs with LIMIT, OFFSET or DISTINCT, would populate joined inheritance subclass objects loaded by the main entity with column values from another row, when the statement also joined to an
_orm.aliased()construct of that same subclass and referred to its columns, such as in ORDER BY.References: #13798
engine
-
[engine] [bug] Fixed issue in
_engine.URL.update_query_pairs()where a key that was repeated with a sequence of strings as its value would produce a nested tuple in_engine.URL.query, causing the URL to fail to render as a string. Passing a sequence of strings as a value, which was indicated by the type annotations but not documented, is now documented, and the annotations for_engine.URL.update_query_pairs()and_engine.URL.update_query_dict()are corrected to accept any sequence of strings rather than only a list.References: #13770
sql
-
[sql] [bug] Fixed issue in cache key generation where calling
_sql.Select.correlate()or_sql.Select.correlate_except()withNonewould not change the cache key of the_sql.Select, so that a statement which disables correlation, or correlates all FROM objects to enclosing SELECTs, could share a cached SQL string with an otherwise identical statement using the default auto-correlation behavior, leading to incorrect SQL being emitted for whichever statement was executed second.References: #13767
-
[sql] [bug] Fixed issue where a
_sql.select()that refers to aCTEonly within_sql.Select.select_from(), as the left side of_sql.Select.join_from(), or within a join that was followed by_sql.Select.with_only_columns(), would not be copied correctly by_sql.Select.params()orvisitors.cloned_traverse(), such that the new parameter values could be ignored when the statement was invoked using the compiled cache, with the original values used instead. On the 2.1 series, where_sql.Select.params()no longer copies the statement, the issue still applies tovisitors.cloned_traverse()and similar traversals.Also fixed a related issue where, if a traversal such as
visitors.replacement_traverse()replaced the target of_sql.Select.join()or_sql.Select.join_from()with aJoin, that join would render twice in the FROM clause of the resulting statement.References: #13791
asyncio
-
[asyncio] [bug] The
asyncio.CancelledErrorthat occurs frequently for tasks cancelled under anyio, where the connection is nonetheless successfully terminated, is now logged by the connection pool at DEBUG level rather than ERROR.References: #13772
postgresql
-
[postgresql] [bug] Fixed issue where reflection of PostgreSQL columns of type
tsqueryorregconfigwould returnNullTypeand emit a warning, even though the_postgresql.TSQUERYand_postgresql.REGCONFIGtypes are provided by the PostgreSQL dialect. These types are now mapped for reflection in the same way as_postgresql.TSVECTOR. Pull request courtesy Lushiyao5.References: #13762