Releases: sqlalchemy/sqlalchemy
2.0.45
2.0.45
Released: December 9, 2025
orm
-
[orm] [bug] Fixed issue where calling
Mapper.add_property()within mapper event
hooks such asMapperEvents.instrument_class(),
MapperEvents.after_mapper_constructed(), or
MapperEvents.before_mapper_configured()would raise an
AttributeErrorbecause the mapper's internal property collections were
not yet initialized. TheMapper.add_property()method now handles
early-stage property additions correctly, allowing properties including
column properties, deferred columns, and relationships to be added during
mapper initialization events. Pull request courtesy G Allajmi.References: #12858
-
[orm] [bug] Fixed issue in Python 3.14 where dataclass transformation would fail when
a mapped class usingMappedAsDataclassincluded a
relationship()referencing a class that was not available at
runtime (e.g., within aTYPE_CHECKINGblock). This occurred when using
Python 3.14's PEP 649 deferred annotations feature, which is the
default behavior without afrom __future__ import annotations
directive.References: #12952
examples
- [examples] [bug] Fixed the "short_selects" performance example where the cache was being
used in all the examples, making it impossible to compare performance with
and without the cache. Less important comparisons like "lambdas" and
"baked queries" have been removed.
sql
-
[sql] [bug] Some improvements to the
_sql.ClauseElement.params()method to
replace bound parameters in a query were made, however the ultimate issue
in #12915 involving ORM_orm.aliased()cannot be fixed fully
until 2.1, where the method is being rewritten to work without relying on
Core cloned traversal.References: #12915
-
[sql] [bug] Fixed issue where using the
ColumnOperators.in_()operator with a
nestedCompoundSelectstatement (e.g. anINTERSECTof
UNIONqueries) would raise aNotImplementedErrorwhen the
nested compound select was the first argument to the outer compound select.
The_scalar_type()internal method now properly handles nested compound
selects.References: #12987
typing
-
[typing] [bug] Fixed typing issue where
Select.with_for_update()would not support
lists of ORM entities or other FROM clauses in the
Select.with_for_update.ofparameter. Pull request courtesy
Shamil.References: #12730
-
[typing] [bug] Fixed typing issue where
coalescewould not return the correct
return type when a nullable form of that argument were passed, even though
this function is meant to select the non-null entry among possibly null
arguments. Pull request courtesy Yannick PÉROUX.
postgresql
-
[postgresql] [usecase] Added support for reflection of collation in types for PostgreSQL.
Thecollationwill be set only if different from the default
one for the type.
Pull request courtesy Denis Laxalde.References: #6511
-
[postgresql] [bug] Fixed issue where PostgreSQL dialect options such as
postgresql_include
onPrimaryKeyConstraintandUniqueConstraintwere
rendered in the wrong position when combined with constraint deferrability
options likedeferrable=True. Pull request courtesy G Allajmi.References: #12867
-
[postgresql] [bug] Fixed the structure of the SQL string used for the
engine_insertmanyvaluesfeature when an explicit sequence with
nextval()is used. The SQL function invocation for the sequence has
been moved from being rendered inline within each tuple inside of VALUES to
being rendered once in the SELECT that reads from VALUES. This change
ensures the function is invoked in the correct order as rows are processed,
rather than assuming PostgreSQL will execute inline function calls within
VALUES in a particular order. While current PostgreSQL versions appear to
handle the previous approach correctly, the database does not guarantee
this behavior for future versions.References: #13015
mysql
-
[mysql] [usecase] Added support for MySQL 8.0.1 +
FOR SHAREto be emitted for the
Select.with_for_update()method, which offers compatibility with
NOWAITandSKIP LOCKED. The new syntax is used only for MySQL when
version 8.0.1 or higher is detected. Pull request courtesy JetDrag.References: #12964
sqlite
-
[sqlite] [bug] [reflection] A series of improvements have been made for reflection of CHECK constraints
on SQLite. The reflection logic now correctly handles table names
containing the strings "CHECK" or "CONSTRAINT", properly supports all four
SQLite identifier quoting styles (double quotes, single quotes, brackets,
and backticks) for constraint names, and accurately parses CHECK constraint
expressions containing parentheses within string literals using balanced
parenthesis matching with string context tracking. Big thanks to
GruzdevAV for new test cases and implementation ideas.References: #12924
-
[sqlite] [bug] Fixed issue where SQLite dialect would fail to reflect constraint names
that contained uppercase letters or other characters requiring quoting. The
regular expressions used to parse primary key, foreign key, and unique
constraint names from theCREATE TABLEstatement have been updated to
properly handle both quoted and unquoted constraint names.References: #12954
tests
- [tests] [change] A noxfile.py has been added to allow testing with nox. This is a direct
port of 2.1's move to nox, however leaves the tox.ini file in place and
retains all test documentation in terms of tox. Version 2.1 will move to
nox fully, including deprecation warnings for tox and new testing
documentation.
2.0.44
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
inMapped[]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 593Annotatedconstructs 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.Inspector
methods, 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 yields
Resultin all cases. For those cases where
CursorResultis known to be returned and the.rowcount
attribute 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()and
ARRAY.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 TABLE
statements 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 requiresawaitin 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
theMutableListclass.
This change also reverts all other functional changes done in
the same change.References: #12802
2.0.43
2.0.43
Released: August 11, 2025
orm
-
[orm] [bug] Fixed issue where using the
post_updatefeature would apply incorrect
"pre-fetched" values to the ORM objects after a multi-row UPDATE process
completed. These "pre-fetched" values would come from any column that had
anColumn.onupdatecallable or a version id generator used by
orm.Mapper.version_id_generator; for a version id generator
that delivered random identifiers like timestamps or UUIDs, this incorrect
data would lead to a DELETE statement against those same rows to fail in
the next step.References: #12748
-
[orm] [bug] Fixed issue where
_orm.mapped_column.use_existing_column
parameter in_orm.mapped_column()would not work when the
_orm.mapped_column()is used inside of anAnnotatedtype alias in
polymorphic inheritance scenarios. The parameter is now properly recognized
and processed during declarative mapping configuration.References: #12787
-
[orm] [bug] Improved the implementation of the
_orm.selectin_polymorphic()
inheritance loader strategy to properly render the IN expressions using
chunks of 500 records each, in the same manner as that of the
_orm.selectinload()relationship loader strategy. Previously, the IN
expression would be arbitrarily large, leading to failures on databases
that have limits on the size of IN expressions including Oracle Database.References: #12790
engine
-
[engine] [usecase] Added new parameter
create_engine.skip_autocommit_rollback
which provides for a per-dialect feature of preventing the DBAPI
.rollback()from being called under any circumstances, if the
connection is detected as being in "autocommit" mode. This improves upon
a critical performance issue identified in MySQL dialects where the network
overhead of the.rollback()call remains prohibitive even if autocommit
mode is set.References: #12784
postgresql
-
[postgresql] [bug] Fixed regression in PostgreSQL dialect where JSONB subscription syntax
would generate incorrect SQL for JSONB-returning functions, causing syntax
errors. The dialect now properly wraps function calls and expressions in
parentheses when using the[]subscription syntax, generating
(function_call)[index]instead offunction_call[index]to comply
with PostgreSQL syntax requirements.References: #12778
oracle
-
[oracle] [usecase] Extended
_oracle.VECTORto support sparse vectors. This update
introduces_oracle.VectorStorageTypeto specify sparse or dense
storage and added_oracle.SparseVector. Pull request courtesy
Suraj Shaw.References: #12711
2.0.42
2.0.42
Released: July 29, 2025
orm
-
[orm] [usecase] Added
dataclass_metadataargument to all ORM attribute constructors
that accept dataclasses parameters, e.g.mapped_column.dataclass_metadata,
relationship.dataclass_metadata, etc.
It's passed to the underlying dataclassmetadataattribute
of the dataclass field. Pull request courtesy Sigmund Lahn.References: #10674
-
[orm] [bug] Implemented the
_orm.defer(),_orm.undefer()and
_orm.load_only()loader options to work for composite attributes, a
use case that had never been supported previously.References: #12593
-
[orm] [bug] Fixed bug where the ORM would pull in the wrong column into an UPDATE when
a key name inside of theValuesBase.values()method could be located
from an ORM entity mentioned in the statement, but where that ORM entity
was not the actual table that the statement was inserting or updating. An
extra check for this edge case is added to avoid this problem.References: #12692
engine
- [engine] Improved validation of execution parameters passed to the
_engine.Connection.execute()and similar methods to
provided a better error when tuples are passed in.
Previously the execution would fail with a difficult to
understand error message.
sql
-
[sql] [usecase] The
_sql.values()construct gains a new method_sql.Values.cte(),
which allows creation of a named, explicit-columnsCTEagainst an
unnamedVALUESexpression, producing a syntax that allows column-oriented
selection from aVALUESconstruct on modern versions of PostgreSQL, SQLite,
and MariaDB.References: #12734
-
[sql] [bug] Fixed issue where
select()of a free-standing scalar expression that
has a unary operator applied, such as negation, would not apply result
processors to the selected column even though the correct type remains in
place for the unary expression.References: #12681
-
[sql] [bug] Hardening of the compiler's actions for UPDATE statements that access
multiple tables to report more specifically when tables or aliases are
referenced in the SET clause; on cases where the backend does not support
secondary tables in the SET clause, an explicit error is raised, and on the
MySQL or similar backends that support such a SET clause, more specific
checking for not-properly-included tables is performed. Overall the change
is preventing these erroneous forms of UPDATE statements from being
compiled, whereas previously it was relied on the database to raise an
error, which was not always guaranteed to happen, or to be non-ambiguous,
due to cases where the parent table included the same column name as the
secondary table column being updated.References: #12692
postgresql
-
[postgresql] [usecase] Added support for PostgreSQL 14+ JSONB subscripting syntax. When connected
to PostgreSQL 14 or later, JSONB columns now automatically use the native
subscript notationjsonb_col['key']instead of the arrow operator
jsonb_col -> 'key'for both read and write operations. This provides
better compatibility with PostgreSQL's native JSONB subscripting feature
while maintaining backward compatibility with older PostgreSQL versions.
JSON columns continue to use the traditional arrow syntax regardless of
PostgreSQL version.References: #10927
-
[postgresql] [usecase] Added
postgresql_opskey to thedialect_optionsentry in reflected
dictionary. This maps names of columns used in the index to respective
operator class, if distinct from the default one for column's data type.
Pull request courtesy Denis Laxalde.References: #8664
-
[postgresql] [bug] [reflection] Fixed regression caused by #10665 where the newly modified
constraint reflection query would fail on older versions of PostgreSQL
such as version 9.6. Pull request courtesy Denis Laxalde.References: #12600
-
[postgresql] [bug] Re-raise catched
CancelledErrorin the terminate method of the
asyncpg dialect to avoid possible hangs of the code execution.References: #12728
-
[postgresql] [bug] [reflection] Fixes bug that would mistakenly interpret a domain or enum type
with name starting inintervalas anINTERVALtype while
reflecting a table.References: #12744
mysql
-
[mysql] [bug] Fixed yet another regression caused by by the DEFAULT rendering changes in
2.0.40 #12425, similar to #12488, this time where using a
CURRENT_TIMESTAMP function with a fractional seconds portion inside a
textual default value would also fail to be recognized as a
non-parenthesized server default.References: #12648
mssql
-
[mssql] [bug] Reworked SQL Server column reflection to be based on the
sys.columns
table rather thaninformation_schema.columnsview. By correctly using
the SQL Serverobject_id()function as a lead and joining to related
tables on object_id rather than names, this repairs a variety of issues in
SQL Server reflection, including:- Issue where reflected column comments would not correctly line up with the columns themselves in the case that the table had been ALTERed - Correctly targets tables with awkward names such as names with brackets, when reflecting not just the basic table / columns but also extended information including IDENTITY, computed columns, comments which did not work previously - Correctly targets IDENTITY, computed status from temporary tables which did not work previouslyReferences: #12654
2.0.41
2.0.41
Released: May 14, 2025
platform
-
[platform] [bug] Adjusted the test suite as well as the ORM's method of scanning classes for
annotations to work under current beta releases of Python 3.14 (currently
3.14.0b1) as part of an ongoing effort to support the production release of
this Python release. Further changes to Python's means of working with
annotations is expected in subsequent beta releases for which SQLAlchemy's
test suite will need further adjustments.References: #12405
engine
-
[engine] [bug] The error message that is emitted when a URL cannot be parsed no longer
includes the URL itself within the error message.References: #12579
typing
-
[typing] [bug] Removed
__getattr__()rule fromsqlalchemy/__init__.pythat
appeared to be trying to correct for a previous typographical error in the
imports. This rule interferes with type checking and is removed.References: #12588
postgresql
-
[postgresql] [usecase] Added support for
postgresql_includekeyword argument to
_schema.UniqueConstraintand_schema.PrimaryKeyConstraint.
Pull request courtesy Denis Laxalde.References: #10665
mysql
-
[mysql] [bug] Fixed regression caused by the DEFAULT rendering changes in version 2.0.40
via #12425 where using lowercaseon updatein a MySQL server
default would incorrectly apply parenthesis, leading to errors when MySQL
interpreted the rendered DDL. Pull request courtesy Alexander Ruehe.References: #12488
sqlite
-
[sqlite] [bug] Fixed and added test support for some SQLite SQL functions hardcoded into
the compiler, most notably thelocaltimestampfunction which rendered
with incorrect internal quoting.References: #12566
oracle
-
[oracle] [usecase] Added new datatype
_oracle.VECTORand accompanying DDL and DQL
support to fully support this type for Oracle Database. This change
includes the base_oracle.VECTORtype that adds new type-specific
methodsl2_distance,cosine_distance,inner_productas well as
new parametersoracle_vectorfor theIndexconstruct,
allowing vector indexes to be configured, andoracle_fetch_approximate
for theSelect.fetch()clause. Pull request courtesy Suraj Shaw.
misc
- [bug] [installation] Removed the "license classifier" from setup.cfg for SQLAlchemy 2.0, which
eliminates loud deprecation warnings when building the package. SQLAlchemy
2.1 will use a full PEP 639 configuration in pyproject.toml while
SQLAlchemy 2.0 remains usingsetup.cfgfor setup.
2.0.40
2.0.40
Released: March 27, 2025
orm
-
[orm] [bug] Fixed regression which occurred as of 2.0.37 where the checked
ArgumentErrorthat's raised when an inappropriate type or object
is used inside of aMappedannotation would raiseTypeError
with "boolean value of this clause is not defined" if the object resolved
into a SQL expression in a boolean context, for programs where future
annotations mode was not enabled. This case is now handled explicitly and
a new error message has also been tailored for this case. In addition, as
there are at least half a dozen distinct error scenarios for intepretation
of theMappedconstruct, these scenarios have all been unified
under a new subclass ofArgumentErrorcalled
MappedAnnotationError, to provide some continuity between these
different scenarios, even though specific messaging remains distinct.References: #12329
-
[orm] [bug] Fixed regression in ORM Annotated Declarative class interpretation caused
bytyping_extension==4.13.0that introduced a different implementation
forTypeAliasTypewhile SQLAlchemy assumed that it would be equivalent
to thetypingversion, leading to pep-695 type annotations not
resolving to SQL types as expected.References: #12473
sql
-
[sql] [usecase] Implemented support for the GROUPS frame specification in window functions
by adding_sql.over.groupsoption to_sql.over()
andFunctionElement.over(). Pull request courtesy Kaan Dikmen.References: #12450
-
[sql] [bug] Fixed issue in
CTEconstructs involving multiple DDL
_sql.Insertstatements with multiple VALUES parameter sets where the
bound parameter names generated for these parameter sets would conflict,
generating a compile time error.References: #12363
-
[sql] [bug] Fixed regression caused by #7471 leading to a SQL compilation
issue where name disambiguation for two same-named FROM clauses with table
aliasing in use at the same time would produce invalid SQL in the FROM
clause with two "AS" clauses for the aliased table, due to double aliasing.References: #12451
asyncio
-
[asyncio] [bug] Fixed issue where
AsyncSession.get_transaction()and
AsyncSession.get_nested_transaction()would fail with
NotImplementedErrorif the "proxy transaction" used by
AsyncSessionwere garbage collected and needed regeneration.References: #12471
postgresql
-
[postgresql] [usecase] Added support for specifying a list of columns for
SET NULLandSET DEFAULTactions ofON DELETEclause of foreign key definition on
PostgreSQL. Pull request courtesy Denis Laxalde.References: #11595
-
[postgresql] [usecase] When building a PostgreSQL
ARRAYliteral using
_postgresql.arraywith an emptyclausesargument, the
_postgresql.array.type_parameter is now significant in that it
will be used to render the resultingARRAY[]SQL expression with a
cast, such asARRAY[]::INTEGER. Pull request courtesy Denis Laxalde.References: #12432
mysql
-
[mysql] [bug] Support has been re-added for the MySQL-Connector/Python DBAPI using the
mysql+mysqlconnector://URL scheme. The DBAPI now works against
modern MySQL versions as well as MariaDB versions (in the latter case it's
required to pass charset/collation explicitly). Note however that
server side cursor support is disabled due to unresolved issues with this
driver.References: #12332
-
[mysql] [bug] Fixed issue in MySQL server default reflection where a default that has
spaces would not be correctly reflected. Additionally, expanded the rules
for when to apply parenthesis to a server default in DDL to suit the
general case of a default string that contains non-word characters such as
spaces or operators and is not a string literal.References: #12425
sqlite
-
[sqlite] [bug] Expanded the rules for when to apply parenthesis to a server default in DDL
to suit the general case of a default string that contains non-word
characters such as spaces or operators and is not a string literal.References: #12425
2.0.39
2.0.39
Released: March 11, 2025
orm
-
[orm] [bug] Fixed bug where using DML returning such as
Insert.returning()with
an ORM model that has_orm.column_property()constructs that contain
subqueries would fail with an internal error.References: #12326
-
[orm] [bug] Fixed bug in ORM enabled UPDATE (and theoretically DELETE) where using a
multi-table DML statement would not allow ORM mapped columns from mappers
other than the primary UPDATE mapper to be named in the RETURNING clause;
they would be omitted instead and cause a column not found exception.References: #12328
-
[orm] [bug] Fixed issue where the "is ORM" flag of a
select()or other ORM
statement would not be propagated to the ORMSessionbased on a
multi-part operator expression alone, e.g. such asCls.attr + Cls.attr + Cls.attror similar, leading to ORM behaviors not taking place for such
statements.References: #12357
-
[orm] [bug] Fixed issue where using
_orm.aliased()around aCTE
construct could cause inappropriate "duplicate CTE" errors in cases where
that aliased construct appeared multiple times in a single statement.References: #12364
sql
-
[sql] [bug] Added new parameters
AddConstraint.isolate_from_tableand
DropConstraint.isolate_from_table, defaulting to True, which
both document and allow to be controllable the long-standing behavior of
these two constructs blocking the given constraint from being included
inline within the "CREATE TABLE" sequence, under the assumption that
separate add/drop directives were to be used.References: #12382
typing
-
[typing] [usecase] Support generic types for compound selects (
_sql.union(),
_sql.union_all(),_sql.Select.union(),
_sql.Select.union_all(), etc) returning the type of the first select.
Pull request courtesy of Mingyu Park.References: #11922
asyncio
-
[asyncio] [bug] Fixed bug where
_asyncio.AsyncResult.scalar(),
_asyncio.AsyncResult.scalar_one_or_none(), and
_asyncio.AsyncResult.scalar_one()would raise anAttributeError
due to a missing internal attribute. Pull request courtesy Allen Ho.References: #12338
postgresql
-
[postgresql] [bug] Add SQL typing to reflection query used to retrieve a the structure
of IDENTITY columns, adding explicit JSON typing to the query to suit
unusual PostgreSQL driver configurations that don't support JSON natively.References: #11751
-
[postgresql] [bug] Fixed issue affecting PostgreSQL 17.3 and greater where reflection of
domains with "NOT NULL" as part of their definition would include an
invalid constraint entry in the data returned by
_postgresql.PGInspector.get_domains()corresponding to an additional
"NOT NULL" constraint that isn't a CHECK constraint; the existing
"nullable"entry in the dictionary already indicates if the domain
includes a "not null" constraint. Note that such domains also cannot be
reflected on PostgreSQL 17.0 through 17.2 due to a bug on the PostgreSQL
side; if encountering errors in reflection of domains which include NOT
NULL, upgrade to PostgreSQL server 17.3 or greater. -
[postgresql] [bug] Fixed issue in PostgreSQL network types
_postgresql.INET,
_postgresql.CIDR,_postgresql.MACADDR,
_postgresql.MACADDR8where sending string values to compare to
these types would render an explicit CAST to VARCHAR, causing some SQL /
driver combinations to fail. Pull request courtesy Denis Laxalde.References: #12060
-
[postgresql] [bug] Fixed compiler issue in the PostgreSQL dialect where incorrect keywords
would be passed when using "FOR UPDATE OF" inside of a subquery.References: #12417
sqlite
-
[sqlite] [bug] Fixed issue that omitted the comma between multiple SQLite table extension
clauses, currentlyWITH ROWIDandSTRICT, when both options
Table.sqlite_with_rowidandTable.sqlite_strict
were configured at their non-default settings at the same time. Pull
request courtesy david-fed.References: #12368
2.0.38
2.0.38
Released: February 6, 2025
engine
-
[engine] [bug] Fixed event-related issue where invoking
Engine.execution_options()
on aEnginemultiple times while making use of event-registering
parameters such asisolation_levelwould lead to internal errors
involving event registration.References: #12289
sql
-
[sql] [bug] Reorganized the internals by which the
.ccollection on a
FromClausegets generated so that it is resilient against the
collection being accessed in concurrent fashion. An example is creating a
AliasorSubqueryand accessing it as a module level
variable. This impacts the Oracle dialect which uses such module-level
global alias objects but is of general use as well.References: #12302
-
[sql] [bug] Fixed SQL composition bug which impacted caching where using a
None
value inside of anin_()expression would bypass the usual "expanded
bind parameter" logic used by the IN construct, which allows proper caching
to take place.References: #12314
postgresql
-
[postgresql] [usecase] [asyncio] Added an additional
asyncio.shield()call within the connection
terminate process of the asyncpg driver, to mitigate an issue where
terminate would be prevented from completing under the anyio concurrency
library.References: #12077
-
[postgresql] [bug] Adjusted the asyncpg connection wrapper so that the
connection.transaction()call sent to asyncpg sendsNonefor
isolation_levelif not otherwise set in the SQLAlchemy dialect/wrapper,
thereby allowing asyncpg to make use of the server level setting for
isolation_levelin the absense of a client-level setting. Previously,
this behavior of asyncpg was blocked by a hardcodedread_committed.References: #12159
mariadb
-
[mariadb] [bug] [dml] [mysql] Fixed a bug where the MySQL statement compiler would not properly compile
statements where_mysql.Insert.on_duplicate_key_update()was passed
values that included ORM-mapped attributes (e.g.
InstrumentedAttributeobjects) as keys. Pull request courtesy of
mingyu.References: #12117
sqlite
-
[sqlite] [bug] [aiosqlite] [asyncio] [pool] Changed default connection pool used by the
aiosqlitedialect
fromNullPooltoAsyncAdaptedQueuePool; this change
should have been made when 2.0 was first released as thepysqlite
dialect was similarly changed to useQueuePoolas detailed
inchange_7490.References: #12285
2.0.37
2.0.37
Released: January 9, 2025
orm
-
[orm] [bug] Fixed issue regarding
Uniontypes that would be present in the
_orm.registry.type_annotation_mapof a_orm.registry
or declarative base class, where aMappedelement that included
one of the subtypes present in thatUnionwould be matched to that
entry, potentially ignoring other entries that matched exactly. The
correct behavior now takes place such that an entry should only match in
_orm.registry.type_annotation_mapexactly, as aUniontype
is a self-contained type. For example, an attribute withMapped[float]
would previously match to a_orm.registry.type_annotation_map
entryUnion[float, Decimal]; this will no longer match and will now
only match to an entry that statesfloat. Pull request courtesy Frazer
McLean.References: #11370
-
[orm] [bug] Fixed bug in how type unions were handled within
_orm.registry.type_annotation_mapas well as
_orm.Mappedthat made the lookup behavior ofa | bdifferent
from that ofUnion[a, b].References: #11944
-
[orm] [bug] Consistently handle
TypeAliasType(defined in PEP 695) obtained with
thetype X = intsyntax introduced in python 3.12. Now in all cases one
such alias must be explicitly added to the type map for it to be usable
insideMapped. This change also revises the approach added in
#11305, now requiring theTypeAliasTypeto be added to the
type map. Documentation on how unions and type alias types are handled by
SQLAlchemy has been added in the
orm_declarative_mapped_column_type_mapsection of the documentation.References: #11955
-
[orm] [bug] Fixed regression caused by an internal code change in response to recent
Mypy releases that caused the very unusual case of a list of ORM-mapped
attribute expressions passed toColumnOperators.in_()to no longer
be accepted.References: #12019
-
[orm] [bug] Fixed issues in type handling within the
_orm.registry.type_annotation_mapfeature which prevented the
use of unions, using either pep-604 orUnionsyntaxes under future
annotations mode, which contained multiple generic types as elements from
being correctly resolvable.References: #12207
-
[orm] [bug] Fixed issue in event system which prevented an event listener from being
attached and detached from multiple class-like objects, namely the
sessionmakerorscoped_sessiontargets that assign to
Sessionsubclasses.References: #12216
sql
-
[sql] [bug] Fixed issue in "lambda SQL" feature where the tracking of bound parameters
could be corrupted if the same lambda were evaluated across multiple
compile phases, including when using the same lambda across multiple engine
instances or with statement caching disabled.References: #12084
postgresql
-
[postgresql] [usecase] The
_postgresql.Rangetype now supports
_postgresql.Range.__contains__(). Pull request courtesy of Frazer
McLean.References: #12093
-
[postgresql] [bug] Fixes issue in
Dialect.get_multi_indexes()in the PostgreSQL
dialect, where an error would be thrown when attempting to use alembic with
a vector index from the pgvecto.rs extension.References: #11724
-
[postgresql] [bug] Fixed issue where creating a table with a primary column of
_sql.SmallIntegerand using the asyncpg driver would result in
the type being compiled toSERIALrather thanSMALLSERIAL.References: #12170
-
[postgresql] [bug] Adjusted the asyncpg dialect so that an empty SQL string, which is valid
for PostgreSQL server, may be successfully processed at the dialect level,
such as when usingConnection.exec_driver_sql(). Pull request
courtesy Andrew Jackson.References: #12220
mysql
-
[mysql] [usecase] [mariadb] Added support for the
LIMITclause withDELETEfor the MySQL and
MariaDB dialects, to complement the already present option for
UPDATE. TheDelete.with_dialect_options()method of the
delete()construct accepts parameters formysql_limitand
mariadb_limit, allowing users to specify a limit on the number of rows
deleted. Pull request courtesy of Pablo Nicolás Estevez.References: #11764
-
[mysql] [bug] [mariadb] Added logic to ensure that the
mysql_limitandmariadb_limit
parameters ofUpdate.with_dialect_options()and
Delete.with_dialect_options()when compiled to string will only
compile if the parameter is passed as an integer; aValueErroris
raised otherwise.
mariadb
-
[mariadb] [usecase] Added sql types
INET4andINET6in the MariaDB dialect. Pull
request courtesy Adam Žurek.References: #10720
sqlite
-
[sqlite] [usecase] Added SQLite table option to enable
STRICTtables. Pull request
courtesy of Guilherme Crocetti.References: #7398
oracle
-
[oracle] [feature] Added new table option
oracle_tablespaceto specify theTABLESPACE
option when creating a table in Oracle. This allows users to define the
tablespace in which the table should be created. Pull request courtesy of
Miguel Grillo.References: #12016
-
[oracle] [usecase] Use the connection attribute
max_identifier_lengthavailable
in oracledb since version 2.5 when determining the identifier length
in the Oracle dialect.References: #12032
-
[oracle] [bug] Fixed compilation of
TABLEfunction when used in aFROMclause in
Oracle Database dialect.References: #12100
-
[oracle] [bug] Fixed issue in oracledb / cx_oracle dialects where output type handlers for
CLOBwere being routed toNVARCHARrather thanVARCHAR, causing
a double conversion to take place.References: #12150
2.0.36
2.0.36
Released: October 15, 2024
orm
-
[orm] [usecase] Added new parameter
_orm.mapped_column.hashto ORM constructs
such as_orm.mapped_column(),_orm.relationship(), etc.,
which is interpreted for ORM Native Dataclasses in the same way as other
dataclass-specific field parameters.References: #11923
-
[orm] [bug] Fixed bug in ORM bulk update/delete where using RETURNING with bulk
update/delete in combination withpopulate_existingwould fail to
accommodate thepopulate_existingoption.References: #11912
-
[orm] [bug] Continuing from #11912, columns marked with
mapped_column.onupdate,
mapped_column.server_onupdate, orComputedare now
refreshed in ORM instances when running an ORM enabled UPDATE with WHERE
criteria, even if the statement does not use RETURNING or
populate_existing.References: #11917
-
[orm] [bug] Fixed regression caused by fixes to joined eager loading in #11449
released in 2.0.31, where a particular joinedload case could not be
asserted correctly. We now have an example of that case so the assertion
has been repaired to allow for it.References: #11965
-
[orm] [bug] Improved the error message emitted when trying to map as dataclass a class
while also manually providing the__table__attribute.
This usage is currently not supported.References: #11973
-
[orm] [bug] Refined the check which the ORM lazy loader uses to detect "this would be
loading by primary key and the primary key is NULL, skip loading" to take
into account the current setting for the
orm.Mapper.allow_partial_pksparameter. If this parameter is
False, then a composite PK value that has partial NULL elements should
also be skipped. This can apply to some composite overlapping foreign key
configurations.References: #11995
-
[orm] [bug] Fixed bug in ORM "update with WHERE clause" feature where an explicit
.returning()would interfere with the "fetch" synchronize strategy due
to an assumption that the ORM mapped class featured the primary key columns
in a specific position within the RETURNING. This has been fixed to use
appropriate ORM column targeting.References: #11997
sql
-
[sql] [usecase] Datatypes that are binary based such as
VARBINARYwill resolve to
LargeBinarywhen theTypeEngine.as_generic()method is
called.References: #11978
-
[sql] [bug] [regression] Fixed regression from 1.4 where some datatypes such as those derived from
TypeDecoratorcould not be pickled when they were part of a
larger SQL expression composition due to internal supporting structures
themselves not being pickleable.References: #12002
schema
-
[schema] [bug] Fixed bug where SQL functions passed to
_schema.Column.server_defaultwould not be rendered with the
particular form of parenthesization now required by newer versions of MySQL
and MariaDB. Pull request courtesy of huuya.References: #11317
postgresql
-
[postgresql] [bug] [reflection] Fixed bug in reflection of table comments where unrelated text would be
returned if an entry in thepg_descriptiontable happened to share the
same oid (objoid) as the table being reflected.References: #11961
-
[postgresql] [bug] The
postgresql.JSONandpostgresql.JSONBdatatypes will
now render a "bind cast" in all cases for all PostgreSQL backends,
including psycopg2, whereas previously it was only enabled for some
backends. This allows greater accuracy in allowing the database server to
recognize when a string value is to be interpreted as JSON.References: #11994
mysql
-
[mysql] [performance] Improved a query used for the MySQL 8 backend when reflecting foreign keys
to be better optimized. Previously, for a database that had millions of
columns across all tables, the query could be prohibitively slow; the query
has been reworked to take better advantage of existing indexes.References: #11975