2.1.9
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
References: #13798
-
[orm] [bug] [regression] Fixed regression caused by #11226 where a relationship to an aliased class against a correlated LATERAL subquery, when loaded with
_orm.joinedload()in a query that includes DISTINCT or GROUP BY, would render the LATERAL without its correlation, returning incorrect rows. The correlated elements within the LATERAL are now adapted along with the rest of the eager join when the query is wrapped in a subquery.References: #13783
-
[orm] [bug] Fixed issue where a relationship to an aliased class against a correlated LATERAL subquery would render the LATERAL without its correlation, returning incorrect rows, when loaded with
_orm.selectinload(),_orm.subqueryload(),_orm.lazyload()or_orm.immediateload(), or when joined or joined eager loaded from an_orm.aliased()parent. The correlated elements within the LATERAL are now adapted to the parent in each of these cases.References: #13786
-
[orm] [bug] [regression] Fixed regression caused by #13748 where an ORM mapped dataclass that included a column using
_orm.orm_insert_sentinel(), or a_orm.mapped_column()given aColumnDefaultorSequenceobject for_orm.mapped_column.default, would fail to flush, as the default object itself would be delivered to the INSERT statement as a parameter value. These objects now apply to theColumnonly, and are no longer used as the Python-side default value of the attribute, which now remainsNoneuntil the object is flushed.References: #13788
engine
-
[engine] [performance] Improved the performance of
_engine.Result.mappings()and_asyncio.AsyncResult.mappings()when the Cython extensions are in use. The conversion of each_engine.Rowinto a_engine.RowMappingis now performed within the compiled extension, rather than through a Python-level access of the_engine.Row._mappingattribute, substantially reducing per-row overhead when fetching rows as mappings.References: #13769
-
[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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
References: #13791
-
[sql] [bug] Split the
OperatorClass.COMPARISONinto equality and ordering operators (OperatorClass.EQUALITYandOperatorClass.ORDERING). The types_postgresql.HSTOREand the type used byFunctionElement.table_valued()now have theOperatorClass.EQUALITYoperator class.References: #13781
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.This change is also backported to: 2.0.58
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.This change is also backported to: 2.0.58
References: #13762
mssql
-
[mssql] [bug] [reflection] Fixed issue where reflection of a table's primary key constraint on SQL Server could block, or deadlock, against another session that was creating a table with a primary key within a transaction, for both regular and temporary tables. The catalog query used for primary key reflection now skips rows that are locked by other sessions.
References: #13789