2.0.44
Released: October 10, 2025
platform
- [platform] [bug] Unblocked automatic greenlet installation for Python 3.14 now that there are greenlet wheels on pypi for python 3.14.
orm
-
[orm] [usecase] The way ORM Annotated Declarative interprets Python PEP 695 type aliases in
Mapped[]annotations has been refined to expand the lookup scheme. A PEP 695 type can now be resolved based on either its direct presence in_orm.registry.type_annotation_mapor its immediate resolved value, as long as a recursive lookup across multiple PEP 695 types is not required for it to resolve. This change reverses part of the restrictions introduced in 2.0.37 as part of #11955, which deprecated (and disallowed in 2.1) the ability to resolve any PEP 695 type that was not explicitly present in_orm.registry.type_annotation_map. Recursive lookups of PEP 695 types remains deprecated in 2.0 and disallowed in version 2.1, as do implicit lookups ofNewTypetypes without an entry in_orm.registry.type_annotation_map.Additionally, new support has been added for generic PEP 695 aliases that refer to PEP 593
Annotatedconstructs containing_orm.mapped_column()configurations. See the sections below for examples.References: #12829
-
[orm] [bug] Fixed a caching issue where
_orm.with_loader_criteria()would incorrectly reuse cached bound parameter values when used with_sql.CompoundSelectconstructs such as_sql.union(). The issue was caused by the cache key for compound selects not including the execution options that are part of the_sql.Executablebase class, which_orm.with_loader_criteria()uses to apply its criteria dynamically. The fix ensures that compound selects and other executable constructs properly include execution options in their cache key traversal.References: #12905
engine
-
[engine] [bug] Implemented initial support for free-threaded Python by adding new tests and reworking the test harness to include Python 3.13t and Python 3.14t in test runs. Two concurrency issues have been identified and fixed: the first involves initialization of the
.ccollection on aFromClause, a continuation of #12302, where an optional mutex under free-threading is added; the second involves synchronization of the pool "first_connect" event, which first received thread synchronization in #2964, however under free-threading the creation of the mutex itself runs under the same free-threading mutex. Support for free-threaded wheels on Pypi is implemented as well within the 2.1 series only. Initial pull request and test suite courtesy Lysandros Nikolaou.References: #12881
sql
-
[sql] [bug] Improved the implementation of
UpdateBase.returning()to use more robust logic in setting up the.ccollection of a derived statement such as a CTE. This fixes issues related to RETURNING clauses that feature expressions based on returned columns with or without qualifying labels.References: #12271
schema
-
[schema] [bug] Fixed issue where
_schema.MetaData.reflect()did not forward dialect-specific keyword arguments to the_engine.Inspectormethods, causing options likeoracle_resolve_synonymsto be ignored during reflection. The method now ensures that all extra kwargs passed to_schema.MetaData.reflect()are forwarded to_engine.Inspector.get_table_names()and related reflection methods. Pull request courtesy Lukáš Kožušník.References: #12884
typing
-
[typing] [bug] Fixed typing bug where the
Session.execute()method advertised that it would return aCursorResultif given an insert/update/delete statement. This is not the general case as several flavors of ORM insert/update do not actually yield aCursorResultwhich cannot be differentiated at the typing overload level, so the method now yieldsResultin all cases. For those cases whereCursorResultis known to be returned and the.rowcountattribute is required, please usetyping.cast().References: #12813
-
[typing] [bug] Added new decorator
_orm.mapped_as_dataclass(), which is a function based form of_orm.registry.mapped_as_dataclass(); the method form_orm.registry.mapped_as_dataclass()does not seem to be correctly recognized within the scope of PEP 681 in recent mypy versions.References: #12855
asyncio
-
[asyncio] [usecase] Generalize the terminate logic employed by the asyncpg dialect to reuse it in the aiomysql and asyncmy dialect implementation.
References: #12273
postgresql
-
[postgresql] [bug] Fixed issue where selecting an enum array column containing NULL values would fail to parse properly in the PostgreSQL dialect. The
_split_enum_values()function now correctly handles NULL entries by converting them to PythonNonevalues.References: #12847
-
[postgresql] [bug] Fixed issue where the
_sql.any_()and_sql.all_()aggregation operators would not correctly coerce the datatype of the compared value, in those cases where the compared value were not a simple int/str etc., such as a PythonEnumor other custom value. This would lead to execution time errors for these values. This issue is essentially the same as #6515 which was for the now-legacyARRAY.any()andARRAY.all()methods.References: #12874
sqlite
-
[sqlite] [bug] Fixed issue where SQLite table reflection would fail for tables using
WITHOUT ROWIDand/orSTRICTtable options when the table contained generated columns. The regular expression used to parseCREATE TABLEstatements for generated column detection has been updated to properly handle these SQLite table options that appear after the column definitions. Pull request courtesy Tip ten Brink.References: #12864
mssql
-
[mssql] [bug] Improved the base implementation of the asyncio cursor such that it includes the option for the underlying driver's cursor to be actively closed in those cases where it requires
awaitin order to complete the close sequence, rather than relying on garbage collection to "close" it, when a plainResultis returned that does not useawaitfor any of its methods. The previous approach of relying on gc was fine for MySQL and SQLite dialects but has caused problems with the aioodbc implementation on top of SQL Server. The new option is enabled for those dialects which have an "awaitable"cursor.close(), which includes the aioodbc, aiomysql, and asyncmy dialects (aiosqlite is also modified for 2.1 only).References: #12798
-
[mssql] [bug] Fixed issue where the index reflection for SQL Server would not correctly return the order of the column inside an index when the order of the columns in the index did not match the order of the columns in the table. Pull request courtesy of Allen Chen.
References: #12894
-
[mssql] [bug] [reflection] Fixed issue in the MSSQL dialect's foreign key reflection query where duplicate rows could be returned when a foreign key column and its referenced primary key column have the same name, and both the referencing and referenced tables have indexes with the same name. This resulted in an "ForeignKeyConstraint with duplicate source column references are not supported" error when attempting to reflect such tables. The query has been corrected to exclude indexes on the child table when looking for unique indexes referenced by foreign keys.
References: #12907
misc
-
[bug] [ext] Fixed issue caused by an unwanted functional change while typing the
MutableListclass. This change also reverts all other functional changes done in the same change.References: #12802