]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 hours agoimprove wording of a phrase in migration notes main
Federico Caselli [Thu, 29 Jan 2026 09:00:35 +0000 (10:00 +0100)] 
improve wording of a phrase in migration notes

12 hours agoMerge "Improve migration notes for 2.1" into main
Michael Bayer [Thu, 29 Jan 2026 01:12:51 +0000 (01:12 +0000)] 
Merge "Improve migration notes for 2.1" into main

17 hours agoImprove migration notes for 2.1
Federico Caselli [Thu, 22 Jan 2026 21:59:37 +0000 (22:59 +0100)] 
Improve migration notes for 2.1

Added syntax extension and PostgreSQL persisted change in Compute

Change-Id: I17d107cdc707dfd798841d9df0a703a94d201ad7

42 hours agoclarify that poolevents should be registered via engines
Mike Bayer [Tue, 27 Jan 2026 18:38:26 +0000 (13:38 -0500)] 
clarify that poolevents should be registered via engines

also clarify the role of engine.dispose()

references: #13097
Change-Id: I495863b58ffd05f4883f51ce2b3dcbd2bb2367b2

4 days agoMerge "ensure links render properly in the docs" into main
Michael Bayer [Sat, 24 Jan 2026 19:21:50 +0000 (19:21 +0000)] 
Merge "ensure links render properly in the docs" into main

5 days agoFix a typo in relationships.rst (#13087)
Imad Saddik [Fri, 23 Jan 2026 22:43:16 +0000 (23:43 +0100)] 
Fix a typo in relationships.rst (#13087)

6 days agoensure links render properly in the docs
Federico Caselli [Thu, 22 Jan 2026 20:56:59 +0000 (21:56 +0100)] 
ensure links render properly in the docs

Change-Id: Ie4d028d45f3c44e07b36a3d4fe16c9663ebe02ba

6 days agofix wheel generation in free-threaded python build
Federico Caselli [Thu, 22 Jan 2026 20:13:28 +0000 (21:13 +0100)] 
fix wheel generation in free-threaded python build

Change-Id: Iebd81d7c6fb15ebe146a3ff20a85c35adc80fe9b

7 days agoremove 12240. rst (note space)
Mike Bayer [Wed, 21 Jan 2026 21:37:03 +0000 (16:37 -0500)] 
remove 12240. rst (note space)

this file got successfully merged into changelog_21 for the 2.1.0b1
release however the file deletion phase missed the file itself,
causing it to render in both 2.1.0b1 and 2.1.0b2 on the site.

Change-Id: I0acf9dcc67694a781ae67a641e9b367706fcbfb3

7 days agoVersion 2.1.0b2 placeholder
Mike Bayer [Wed, 21 Jan 2026 20:57:09 +0000 (15:57 -0500)] 
Version 2.1.0b2 placeholder

7 days ago- 2.1.0b1 rel_2_1_0b1
Mike Bayer [Wed, 21 Jan 2026 19:26:27 +0000 (14:26 -0500)] 
- 2.1.0b1

7 days agoMerge "change float -> Double in the _type_map." into main
Federico Caselli [Wed, 21 Jan 2026 18:35:28 +0000 (18:35 +0000)] 
Merge "change float -> Double in the _type_map." into main

7 days agocherry-pick changelog update for 2.0.47
Mike Bayer [Wed, 21 Jan 2026 18:04:03 +0000 (13:04 -0500)] 
cherry-pick changelog update for 2.0.47

7 days agocherry-pick changelog from 2.0.46
Mike Bayer [Wed, 21 Jan 2026 18:04:02 +0000 (13:04 -0500)] 
cherry-pick changelog from 2.0.46

7 days agoMerge "make qtoken for PostgreSQL _fk_regex_pattern less restrictive" into main
Michael Bayer [Wed, 21 Jan 2026 17:57:47 +0000 (17:57 +0000)] 
Merge "make qtoken for PostgreSQL _fk_regex_pattern less restrictive" into main

8 days agochange float -> Double in the _type_map.
Mike Bayer [Tue, 20 Jan 2026 14:45:25 +0000 (09:45 -0500)] 
change float -> Double in the _type_map.

The :class:`.Double` type is now used when a Python float value is detected
as a literal value to be sent as a bound parameter, rather than the
:class:`.Float` type.  :class:`.Double` has the same implementation as
:class:`.Float`, but when rendered in a CAST, produces ``DOUBLE`` or
``DOUBLE PRECISION`` rather than ``FLOAT``.   The former better matches
Python's ``float`` datatype which uses 8-byte double-precision storage.
Third party dialects which don't support the :class:`.Double` type directly
may need adjustment so that they render an appropriate keyword (e.g.
``FLOAT``) when the :class:`.Double` datatype is encountered.

Fixes: #10300
Change-Id: I6d221ca9206a10c73fefad55f7ab7a6da5c81d6b

8 days agomake qtoken for PostgreSQL _fk_regex_pattern less restrictive
Gord Thompson [Mon, 19 Jan 2026 12:34:28 +0000 (05:34 -0700)] 
make qtoken for PostgreSQL _fk_regex_pattern less restrictive

Improved the foreign key reflection regular expression pattern used by the
PostgreSQL dialect to be more permissive in matching identifier characters,
allowing it to correctly handle unicode characters in table and column
names. This change improves compatibility with PostgreSQL variants such as
CockroachDB that may use different quoting patterns in combination with
unicode characters in their identifiers.  Pull request courtesy Gord
Thompson.

Change-Id: Iaee340879400e01df2f776417e8b1018f1801cfe

8 days agoMerge "Update generic associations examples for strict typing" into main
Michael Bayer [Wed, 21 Jan 2026 01:04:25 +0000 (01:04 +0000)] 
Merge "Update generic associations examples for strict typing" into main

8 days agodocs: fix grammar in reflection documentation 13084/head
Imad Saddik [Tue, 20 Jan 2026 20:52:24 +0000 (21:52 +0100)] 
docs: fix grammar in reflection documentation

8 days agoUpdate generic associations examples for strict typing
Mike Fiedler [Tue, 20 Jan 2026 18:22:46 +0000 (13:22 -0500)] 
Update generic associations examples for strict typing

### Description

Following previous work in #10450 and #12031, add more type hints to the examples.

I added a new test case to exercise these examples in the future as well.

### Checklist

This pull request is:

- [x] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed

**Have a nice day!**

Closes: #13082
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13082
Pull-request-sha: 7a2bed3f6d9fe33c621ac2a6ca56364fa5fe7053

Change-Id: Ia143abbc4c8491c2976203d1b99162652b26b417

11 days agoexclude 3.14t + windows arm
Mike Bayer [Sat, 17 Jan 2026 16:48:21 +0000 (11:48 -0500)] 
exclude 3.14t + windows arm

Change-Id: I8bd9c9cd5994f81a5758a99ef11cb0bc2d0d8f90

11 days agodoc fixes
Mike Bayer [Sat, 17 Jan 2026 16:42:24 +0000 (11:42 -0500)] 
doc fixes

Change-Id: Ica5aebe16e139dda8035e84f1966805e50c008b6

12 days agoseparate out mariadb/mysql implementations but remain monolithic
Mike Bayer [Wed, 14 Jan 2026 16:06:50 +0000 (11:06 -0500)] 
separate out mariadb/mysql implementations but remain monolithic

Fixes to the MySQL/MariaDB dialect so that mariadb-specific features such
as the :class:`.mariadb.INET4` and :class:`.mariadb.INET6` datatype may be
used with an :class:`.Engine` that uses a ``mysql://`` URL, if the backend
database is actually a mariadb database.   Previously, support for MariaDB
features when ``mysql://`` URLs were used instead of ``mariadb://`` URLs
was ad-hoc; with this issue resolution, the full set of schema / compiler /
type features are now available regardless of how the URL was presented.

After much discussion it seems premature to formally separate the
mysql/mariadb dialects to be mutually exclusive, however we'd like
to standardize on how dialect-exclusive behaviors are architected.
For now, use an approach of MariaDB "shim" classes which provide
MariaDB behaviors into all relevant MySQL classes up front.  Where
behaviors are mutually exclusive, support `_set_mariadb()` methods
that enable the mariadb version of things.

this approach may or may not have resilience against future
divergences in mysql/mariadb , but at least starts to separate the
source code for the two databases and hopefully provides a clearer
separation of concerns.

Fixes: #13076
Change-Id: I42cffc0563a2c65c38e854e9cc2181353b230c44

12 days agoMerge "correct mariadb sequence behavior when cycle=False" into main
Michael Bayer [Fri, 16 Jan 2026 15:38:31 +0000 (15:38 +0000)] 
Merge "correct mariadb sequence behavior when cycle=False" into main

12 days agocorrect mariadb sequence behavior when cycle=False
rusher [Wed, 14 Jan 2026 14:03:00 +0000 (09:03 -0500)] 
correct mariadb sequence behavior when cycle=False

Fixed the SQL compilation for the mariadb sequence "NOCYCLE" keyword that
is to be emitted when the :paramref:`.Sequence.cycle` parameter is set to
False on a :class:`.Sequence`.  Pull request courtesy Diego Dupin.

Fixes: #13073
Closes: #13074
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13074
Pull-request-sha: ead18a04018db6d574a3bc4bd71f21c23256737c

Change-Id: Ie1640c969aaa64e41da334fe0eff21e0d12a8bf0

2 weeks agoadd additional clarification re: table valued for SQLite vs. PostgreSQL
Mike Bayer [Wed, 14 Jan 2026 18:43:26 +0000 (13:43 -0500)] 
add additional clarification re: table valued for SQLite vs. PostgreSQL

Fixes: #13079
Change-Id: I4e96709712a3f365e75b134dadc3bd24fb0cc053

2 weeks agohappy new year
Mike Bayer [Wed, 14 Jan 2026 17:55:08 +0000 (12:55 -0500)] 
happy new year

Change-Id: Ia4a184f6a0d4a069e36b1b68be99a3e948c11125

2 weeks agoMerge "Deprecate DropConstraint.isolate_from_table" into main
Michael Bayer [Tue, 13 Jan 2026 19:21:22 +0000 (19:21 +0000)] 
Merge "Deprecate DropConstraint.isolate_from_table" into main

2 weeks agotyping updates to accept with_polymorphic(), aliases
Mike Bayer [Tue, 13 Jan 2026 14:19:14 +0000 (09:19 -0500)] 
typing updates to accept with_polymorphic(), aliases

Fixed typing issues where ORM mapped classes and aliased entities could not
be used as keys in result row mappings or as join targets in select
statements. Patterns such as ``row._mapping[User]``,
``row._mapping[aliased(User)]``, ``row._mapping[with_polymorphic(...)]``
(rejected by both mypy and Pylance), and ``.join(aliased(User))``
(rejected by Pylance) are documented and fully supported at runtime but
were previously rejected by type checkers. The type definitions for
:class:`._KeyType` and :class:`._FromClauseArgument` have been updated to
accept these ORM entity types.

Fixes: #13075
Change-Id: Icc3b1ef832b01fd205b1409b2f6d0f211395d4ad

2 weeks agoDeprecate DropConstraint.isolate_from_table
Federico Caselli [Wed, 26 Nov 2025 21:13:50 +0000 (22:13 +0100)] 
Deprecate DropConstraint.isolate_from_table

The the parameter :paramref:`_schema.DropConstraint.isolate_from_table`
was deprecated since it has no effect on the drop table behavior.
Its default values was also changed to ``False``.

Fixes: #13006
Change-Id: Ibaa68e78da301a4f2a200f8c7abb2dc099fef37a

2 weeks agoMerge "mark has()/any() as ORM; adjust criteria in WHERE without explicit FROM" into...
Michael Bayer [Sun, 11 Jan 2026 02:02:18 +0000 (02:02 +0000)] 
Merge "mark has()/any() as ORM; adjust criteria in WHERE without explicit FROM" into main

2 weeks agomark has()/any() as ORM; adjust criteria in WHERE without explicit FROM
Mike Bayer [Thu, 8 Jan 2026 21:37:38 +0000 (16:37 -0500)] 
mark has()/any() as ORM; adjust criteria in WHERE without explicit FROM

A significant change to the ORM mechanics involved with both
:func:`.orm.with_loader_criteria` as well as single table inheritance, to
more aggressively locate WHERE criteria which should be augmented by either
the custom criteria or single-table inheritance criteria; SELECT statements
that do not include the entity within the columns clause or as an explicit
FROM, but still reference the entity within the WHERE clause, are now
covered, in particular this will allow subqueries using ``EXISTS (SELECT
1)`` such as those rendered by :meth:`.RelationshipProperty.Comparator.any`
and :meth:`.RelationshipProperty.Comparator.has`.

Fixes: #13070
Change-Id: I9afb48e1c95b9e61f4e1b6be8e4a634ed5b1df43

2 weeks agoclarify default_factory
Mike Bayer [Fri, 9 Jan 2026 14:07:23 +0000 (09:07 -0500)] 
clarify default_factory

References: #13068
Change-Id: Ie08ad4120a21bf24c8e5704340c525299b9894fd

3 weeks agoMerge "apply Grouping on left side of JSONB subscript in compiler" into main
Michael Bayer [Wed, 7 Jan 2026 12:52:43 +0000 (12:52 +0000)] 
Merge "apply Grouping on left side of JSONB subscript in compiler" into main

3 weeks agoapply Grouping on left side of JSONB subscript in compiler
Mike Bayer [Wed, 7 Jan 2026 01:03:10 +0000 (20:03 -0500)] 
apply Grouping on left side of JSONB subscript in compiler

Fixed regression in PostgreSQL dialect where JSONB subscription syntax
would generate incorrect SQL for :func:`.cast` expressions returning JSONB,
causing syntax errors. The dialect now properly wraps cast expressions in
parentheses when using the ``[]`` subscription syntax, generating
``(CAST(...))[index]`` instead of ``CAST(...)[index]`` to comply with
PostgreSQL syntax requirements. This extends the fix from :ticket:`12778`
which addressed the same issue for function calls.

This reverts how we did the fix for #12778 in Function.self_group()
and instead moves to a direct Grouping() applied in the PG compiler
based on isinstance of the left side.

in retrospect, when we first did #10927, we **definitely** made
the completely wrong choice in how to do this, the original idea
to detect when we were in an UPDATE and use [] only then was
by **far** what we should have done, given the fact that PG indexes
are based on exact syntax matches.  but since we've made everyone
switch to [] format for their indexes now we can't keep going
back and forth.   even though PG would like [] to be the defacto
syntax it simply is not.    We should potentially pursue a dialect/
create_engine option to switch the use of [] back to -> for
all cases except UPDATE.

Fixes: #13067
Change-Id: I2e0d0f45ebb820d2a8f214550f1d1a500bae223b

3 weeks agoMerge "Fixed JSONB path_match and path_exists operators to use correct type coercion...
Michael Bayer [Wed, 7 Jan 2026 00:09:50 +0000 (00:09 +0000)] 
Merge "Fixed JSONB path_match and path_exists operators to use correct type coercion" into main

3 weeks agoMerge "improved immutabledict merge_with and union" into main
Michael Bayer [Fri, 2 Jan 2026 21:32:36 +0000 (21:32 +0000)] 
Merge "improved immutabledict merge_with and union" into main

3 weeks agoMerge "we probably dont need ORDER BY for selectin_polymorphic" into main
Michael Bayer [Fri, 2 Jan 2026 19:52:30 +0000 (19:52 +0000)] 
Merge "we probably dont need ORDER BY for selectin_polymorphic" into main

3 weeks agowe probably dont need ORDER BY for selectin_polymorphic
Mike Bayer [Thu, 1 Jan 2026 16:39:45 +0000 (11:39 -0500)] 
we probably dont need ORDER BY for selectin_polymorphic

Removed the ``ORDER BY`` clause from queries generated by
:func:`_orm.selectin_polymorphic` and the
:paramref:`_orm.Mapper.polymorphic_load` parameter set to ``"selectin"``.
The ``ORDER BY`` clause appears to have been an unnecessary implementation
artifact.

Fixes: #13060
Change-Id: If563844cbca54f507421d5dcd1ab67afdabb10fc

3 weeks agoMerge "Support aiosqlite 0.22.0+" into main
Michael Bayer [Thu, 1 Jan 2026 22:42:27 +0000 (22:42 +0000)] 
Merge "Support aiosqlite 0.22.0+" into main

3 weeks agoimproved immutabledict merge_with and union
LucasMalor [Tue, 23 Dec 2025 16:28:35 +0000 (11:28 -0500)] 
improved immutabledict merge_with and union

Now `immutabledict.merge_with is an alias of `immutabledict.union`,
both accept multiple arguments.
The methods now avoid doing copies of not required: if the method is
called only one `immutabledict` that's not empty it's returned.

Fixes: #13043
Closes: #13042
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13042
Pull-request-sha: bd53e488432edd5986c28f196b0363b976b26b04

Change-Id: I8078f239e1ca36994b488b15f2fac40facf7f249

3 weeks agoSupport aiosqlite 0.22.0+
Federico Caselli [Wed, 24 Dec 2025 13:02:17 +0000 (14:02 +0100)] 
Support aiosqlite 0.22.0+

Fixed issue in the aiosqlite driver where SQLAlchemy's setting of
aiosqlite's worker thread to "daemon" stopped working because the aiosqlite
architecture moved the location of the worker thread in version 0.22.0.
This "daemon" flag is necessary so that a program is able to exit if the
SQLite connection itself was not explicitly closed, which is particularly
likely with SQLAlchemy as it maintains SQLite connections in a connection
pool.  While it's perfectly fine to call :meth:`.AsyncEngine.dispose`
before program exit, this is not historically or technically necessary for
any driver of any known backend, since a primary feature of relational
databases is durability.  The change also implements support for
"terminate" with aiosqlite when using version version 0.22.1 or greater,
which implements a sync ``.stop()`` method.

Fixes: #13039
Change-Id: I46efcbaab9dd028f673e113d5f6f2ceddfd133ca

3 weeks agoFixed JSONB path_match and path_exists operators to use correct type coercion
Mike Bayer [Wed, 31 Dec 2025 20:48:44 +0000 (15:48 -0500)] 
Fixed JSONB path_match and path_exists operators to use correct type coercion

Fixed issue where PostgreSQL JSONB operators
:meth:`_postgresql.JSONB.Comparator.path_match` and
:meth:`_postgresql.JSONB.Comparator.path_exists` were applying incorrect
``VARCHAR`` casts to the right-hand side operand when used with newer
PostgreSQL drivers such as psycopg. The operators now indicate the
right-hand type as ``JSONPATH``, which currently results in no casting
taking place, but is also compatible with explicit casts if the
implementation were require it at a later point.

Fixes: #13059
Change-Id: I8e1a58361456f7efabf4940339cb5ce2c5a1d5f9

4 weeks agodont run oracledb async on profiling tests
Mike Bayer [Wed, 31 Dec 2025 14:46:57 +0000 (09:46 -0500)] 
dont run oracledb async on profiling tests

this was never the intention

Change-Id: Iaaa208299f377da8afafea7f487c055e170fbc9e

5 weeks agoMerge "Support for `IF EXISTS` in SQL Server 2016 (13.x) and later versions" into...
Michael Bayer [Fri, 19 Dec 2025 21:41:28 +0000 (21:41 +0000)] 
Merge "Support for `IF EXISTS` in SQL Server 2016 (13.x) and later versions" into main

5 weeks agofix typos (#13047)
Fardin Alizadeh [Fri, 19 Dec 2025 20:24:23 +0000 (23:54 +0330)] 
fix typos (#13047)

* fix typos

* fix typos

* fix typos

---------

Co-authored-by: fardyn <fa.alizadeh@pm.me>
5 weeks agoMerge "handle polymorphic_discriminator in query_expression" into main
Michael Bayer [Fri, 19 Dec 2025 20:04:08 +0000 (20:04 +0000)] 
Merge "handle polymorphic_discriminator in query_expression" into main

5 weeks agoSupport for `IF EXISTS` in SQL Server 2016 (13.x) and later versions
Edgar Ramírez Mondragón [Thu, 18 Dec 2025 19:58:59 +0000 (14:58 -0500)] 
Support for `IF EXISTS` in SQL Server 2016 (13.x) and later versions

Added support for the ``IF EXISTS`` clause when dropping indexes on SQL
Server 2016 (13.x) and later versions. The :paramref:`.DropIndex.if_exists`
parameter is now honored by the SQL Server dialect, allowing conditional
index drops that will not raise an error if the index does not exist.
Pull request courtesy Edgar Ramírez Mondragón.

Fixes: #13045
Closes: #13046
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13046
Pull-request-sha: 65dca2055cb403430730b5cf42f0c5f55b23bfb1

Change-Id: Iab95b1a46003b38709a791b8a7c4233dfda5e830

5 weeks agohandle polymorphic_discriminator in query_expression
Mike Bayer [Thu, 18 Dec 2025 16:15:46 +0000 (11:15 -0500)] 
handle polymorphic_discriminator in query_expression

Added support for using :func:`_orm.with_expression` to populate a
:func:`_orm.query_expression` attribute that is also configured as the
``polymorphic_on`` discriminator column. The ORM now detects when a query
expression column is serving as the polymorphic discriminator and updates
it to use the column provided via :func:`_orm.with_expression`, enabling
polymorphic loading to work correctly in this scenario. This allows for
patterns such as where the discriminator value is computed from a related
table.

Fixes: #12631
Change-Id: I20baf4cddc5a19664bf73764f9371b187686af68

5 weeks agofix typos (#13038)
Fardin Alizadeh [Thu, 18 Dec 2025 20:18:42 +0000 (23:48 +0330)] 
fix typos (#13038)

* fix typos

* fix typos

---------

Co-authored-by: fardyn <fa.alizadeh@pm.me>
5 weeks agoMerge "mention adapt on names" into main
Michael Bayer [Thu, 18 Dec 2025 15:04:08 +0000 (15:04 +0000)] 
Merge "mention adapt on names" into main

5 weeks agomention adapt on names
Mike Bayer [Thu, 18 Dec 2025 14:19:12 +0000 (09:19 -0500)] 
mention adapt on names

make sure we include that column correspondence is not
the only way to do this

Change-Id: I4fa78f2e79585c1796c3dc169f88c849d604f668

6 weeks agofix typos (#13036)
Fardin [Tue, 16 Dec 2025 20:10:03 +0000 (23:40 +0330)] 
fix typos (#13036)

6 weeks agoupdate default driver for oracle, postgresql
Mike Bayer [Mon, 15 Dec 2025 19:53:48 +0000 (14:53 -0500)] 
update default driver for oracle, postgresql

The default DBAPI driver for the Oracle Database dialect has been changed
to ``oracledb`` instead of ``cx_oracle``. The ``cx_oracle`` driver remains
fully supported and can be explicitly specified in the connection URL
using ``oracle+cx_oracle://``.

The default DBAPI driver for the PostgreSQL dialect has been changed to
``psycopg`` (psycopg version 3) instead of ``psycopg2``. The ``psycopg2``
driver remains fully supported and can be explicitly specified in the
connection URL using ``postgresql+psycopg2://``.

Fixes: #13010
Change-Id: Ie75810f4c3af609d20da63289d2662dfa2385ca2

6 weeks agoimprove SQL Server fulltext drop
Mike Bayer [Sun, 14 Dec 2025 03:37:04 +0000 (22:37 -0500)] 
improve SQL Server fulltext drop

Change-Id: I848080227d50ab446a8add296b759003441fd0ad

7 weeks agoMerge "Fix return type hint for `Query.get()`" into main
Michael Bayer [Wed, 10 Dec 2025 20:44:28 +0000 (20:44 +0000)] 
Merge "Fix return type hint for `Query.get()`" into main

7 weeks agoupdate wheels and test pipelines
Federico Caselli [Wed, 10 Dec 2025 20:23:08 +0000 (21:23 +0100)] 
update wheels and test pipelines

Change-Id: If4bf769cf6c2c7e069b4db8ae42fdd01de1a2e38

7 weeks agoMerge "modernize annotationlib approach" into main
Michael Bayer [Wed, 10 Dec 2025 18:43:34 +0000 (18:43 +0000)] 
Merge "modernize annotationlib approach" into main

7 weeks agoFix return type hint for `Query.get()`
Séamus Ó Ceanainn [Wed, 10 Dec 2025 17:14:25 +0000 (12:14 -0500)] 
Fix return type hint for `Query.get()`

<!-- Provide a general summary of your proposed changes in the Title field above -->

<!-- Describe your changes in detail -->

`Query[_T].get(...)` should return `Optional[_T]` instead of `Optional[Any]`. This is typed correctly when migrating to  `Session.get(_T, ...)`. By typing the legacy `Query.get(...)` call first, it should make migrations easier on developers, as it splits up the type checking improvements (and subsequent errors which may be discovered) from the `Query.get()`
 to `Session.get()` migration.

<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [x] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #13028
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13028
Pull-request-sha: 38ec0c3ae072f8c7b62134dd017579a6a249219f

Change-Id: I7ae8e59bc0bd0a25c65de3804d60f6c2b6f50151

7 weeks agomodernize annotationlib approach
Michael Bayer [Sat, 6 Dec 2025 15:38:30 +0000 (15:38 +0000)] 
modernize annotationlib approach

This reverts commit 4ff1d604f9bec061fb1936b80d3ed09979d930e8 which reverted this change originally,
so it restores the change.

Change continues here where we now use py314's built in
annotationlib for get_annotations; issue [1] was fixed long
ago before 3.14.0 was released.

change for now:

A change in the mechanics of how Python dataclasses are applied to classes
that use :class:`.MappedAsDataclass` or
:meth:`.registry.mapped_as_dataclass` to apply ``__annotations__`` that are
as identical as is possible to the original ``__annotations__`` given,
while also adding attributes that SQLAlchemy considers to be part of
dataclass ``__annotations__``, then restoring the previous annotations in
exactly the same format as they were, using patterns that work with
:pep:`649` as closely as possible.

[1] https://github.com/python/cpython/issues/133684

Change-Id: I9073f99bc81b466888000da7d51d98cebf272b81

7 weeks agoMerge "use cython for result" into main
Federico Caselli [Wed, 10 Dec 2025 16:17:52 +0000 (16:17 +0000)] 
Merge "use cython for result" into main

7 weeks agoMerge "additional check for dc test" into main
Michael Bayer [Wed, 10 Dec 2025 14:34:47 +0000 (14:34 +0000)] 
Merge "additional check for dc test" into main

7 weeks agoadd length, take two
Mike Bayer [Wed, 10 Dec 2025 14:19:23 +0000 (09:19 -0500)] 
add length, take two

followup to 292aa19698326793003

Change-Id: I283059eaf747c722b871afa55aaeaa2889862584

7 weeks agoadd length
Mike Bayer [Wed, 10 Dec 2025 13:38:03 +0000 (08:38 -0500)] 
add length

new tests in e4a802f99a for issue #12858 forgot to add string
length for String leading to MySQL failures

Change-Id: I7642ee8581da09a3a25236dacdc441effee21931

7 weeks agoadditional check for dc test
Federico Caselli [Tue, 9 Dec 2025 21:40:02 +0000 (22:40 +0100)] 
additional check for dc test

Change-Id: Ibf39a4c413b445abd8825ded900ac451ab9de9a2

7 weeks agocherry-pick changelog update for 2.0.46
Mike Bayer [Tue, 9 Dec 2025 21:06:37 +0000 (16:06 -0500)] 
cherry-pick changelog update for 2.0.46

7 weeks agocherry-pick changelog from 2.0.45
Mike Bayer [Tue, 9 Dec 2025 21:06:36 +0000 (16:06 -0500)] 
cherry-pick changelog from 2.0.45

7 weeks agoMerge "Factor out constraints into separate methods" into main
Michael Bayer [Tue, 9 Dec 2025 20:45:27 +0000 (20:45 +0000)] 
Merge "Factor out constraints into separate methods" into main

7 weeks agoMerge "Fix adding property to mapper before mapping is complete" into main
Michael Bayer [Tue, 9 Dec 2025 20:43:35 +0000 (20:43 +0000)] 
Merge "Fix adding property to mapper before mapping is complete" into main

7 weeks agoFactor out constraints into separate methods
G Allajmi [Tue, 9 Dec 2025 19:13:52 +0000 (14:13 -0500)] 
Factor out constraints into separate methods

Fixed issue where PostgreSQL dialect options such as ``postgresql_include``
on :class:`.PrimaryKeyConstraint` and :class:`.UniqueConstraint` were
rendered in the wrong position when combined with constraint deferrability
options like ``deferrable=True``. Pull request courtesy G Allajmi.

Fixes: #12867
Closes: #13003
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13003
Pull-request-sha: 1a9216062f12cba2695b0b4a1407e092556c2305

Change-Id: I8c55d8faae25d56ff63c9126d569c01d8ee6c7dd

7 weeks agoFix adding property to mapper before mapping is complete
G Allajmi [Mon, 8 Dec 2025 13:03:49 +0000 (08:03 -0500)] 
Fix adding property to mapper before mapping is complete

Fixed issue where calling :meth:`.Mapper.add_property` within mapper event
hooks such as :meth:`.MapperEvents.instrument_class`,
:meth:`.MapperEvents.after_mapper_constructed`, or
:meth:`.MapperEvents.before_mapper_configured` would raise an
``AttributeError`` because the mapper's internal property collections were
not yet initialized. The :meth:`.Mapper.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.

Fixes: #12858
Closes: #13023
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13023
Pull-request-sha: fa9a0ae4bb07819307e6c9d6ec5fd4c9706bf67e

Change-Id: Ibb794c401102a8d23d157b40353f272d5735b49a

7 weeks agouse os.urandom() for CTE, aliased anon id
Mike Bayer [Tue, 9 Dec 2025 14:07:20 +0000 (09:07 -0500)] 
use os.urandom() for CTE, aliased anon id

Fixed issue where anonymous label generation for :class:`.CTE` constructs
could produce name collisions when Python's garbage collector reused memory
addresses during complex query compilation. The anonymous name generation
for :class:`.CTE` and other aliased constructs like :class:`.Alias`,
:class:`.Subquery` and others now use :func:`os.urandom` to generate unique
identifiers instead of relying on object ``id()``, ensuring uniqueness even
in cases of aggressive garbage collection and memory reuse.

Fixes: #12990
Change-Id: If56a53840684bc7d2b7637f1e154dfed1cac5f32

7 weeks agouse cython for result
Federico Caselli [Thu, 13 Nov 2025 21:22:03 +0000 (22:22 +0100)] 
use cython for result

Use cython for the internal result methods. This improves the speed
of the row processing of about 15-30% depending on cases.

Change-Id: Ia19c1a61aa1a55405b8327f88b1ee02627c4217a

7 weeks agoupdate cibuildwheel to ensure python 3.14 is supported
Federico Caselli [Mon, 8 Dec 2025 20:12:16 +0000 (21:12 +0100)] 
update cibuildwheel to ensure python 3.14 is supported

Change-Id: Ic520ae7084dcc0660da0d70a0c33de251395ec50

7 weeks agofix typo
Mike Bayer [Mon, 8 Dec 2025 16:40:34 +0000 (11:40 -0500)] 
fix typo

Change-Id: I5a440f9d3a8bb5afb45b0af4d9f1a112255d5f96

7 weeks agoMerge "support monotonic functions as sentinels" into main
Michael Bayer [Sun, 7 Dec 2025 14:16:09 +0000 (14:16 +0000)] 
Merge "support monotonic functions as sentinels" into main

7 weeks agosupport monotonic functions as sentinels
Mike Bayer [Mon, 1 Dec 2025 16:07:24 +0000 (11:07 -0500)] 
support monotonic functions as sentinels

Added support for monotonic server-side functions such as PostgreSQL 18's
``uuidv7()`` to work with the :ref:`engine_insertmanyvalues` feature.
By passing ``monotonic=True`` to any :class:`.Function`, the function can
be used as a sentinel for tracking row order in batched INSERT operations
with RETURNING, allowing the ORM and Core to efficiently batch INSERT
statements while maintaining deterministic row ordering.

Fixes: #13014
Change-Id: I2fabf96c8fbdb6c1d255fd4781cbd31fed17e1e9

7 weeks agoMerge "Revert "behave more like dataclasses when creating them"" into main
Michael Bayer [Sat, 6 Dec 2025 15:36:48 +0000 (15:36 +0000)] 
Merge "Revert "behave more like dataclasses when creating them"" into main

7 weeks agoRevert "behave more like dataclasses when creating them"
Michael Bayer [Sat, 6 Dec 2025 15:07:25 +0000 (15:07 +0000)] 
Revert "behave more like dataclasses when creating them"

This reverts commit be4e3e675e7f69a2e728af2aa814524173d7a66c.

Reason for revert: everything has passed very well on jenkins, however GH actions is showing the two new test_cpython_142214 tests from 133f14dabed44f7398039 suddenly failing across hundreds of scenarios.  given the risk of this change since dataclasses are very weird, need to see what this is about.   im suspecting point release changes in older pythons like 3.10, 3.11, etc. which seems a bit ominous.

Change-Id: I7c98085b5e3482cad3291194e2ab1f8018db2eff

7 weeks agoMerge "behave more like dataclasses when creating them" into main
Michael Bayer [Sat, 6 Dec 2025 14:09:35 +0000 (14:09 +0000)] 
Merge "behave more like dataclasses when creating them" into main

7 weeks agofix / modernize short_selects example
Mike Bayer [Fri, 5 Dec 2025 22:41:56 +0000 (17:41 -0500)] 
fix / modernize short_selects example

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.

Change-Id: Ia55391ba23e01d2ed136c84f9c34bb16689ce10e

7 weeks agobehave more like dataclasses when creating them
Federico Caselli [Thu, 4 Dec 2025 21:00:32 +0000 (22:00 +0100)] 
behave more like dataclasses when creating them

A change in the mechanics of how Python dataclasses are applied to classes
that use :class:`.MappedAsDataclass` or
:meth:`.registry.mapped_as_dataclass`, to no longer modify the
`__annotations__` collection that's on the class, instead manipulating
regular class-bound attributes in order to satisfy the class requirements
for the dataclass creation function.  This works around an issue that has
appeared in Python 3.14.1, provides for a much simpler implementation, and
also maintains accurate typing information about the attributes as the
dataclass is built.

Fixes: #13021
Change-Id: I6ae13db7f647ad04e202667d69f2b1bb385c032d

7 weeks agofilter_by works across multiple entities
Mike Bayer [Fri, 21 Nov 2025 15:41:40 +0000 (10:41 -0500)] 
filter_by works across multiple entities

The :meth:`_sql.Select.filter_by`, :meth:`_sql.Update.filter_by` and
:meth:`_sql.Delete.filter_by` methods now search across all entities
present in the statement, rather than limiting their search to only the
last joined entity or the first FROM entity. This allows these methods
to locate attributes unambiguously across multiple joined tables,
resolving issues where changing the order of operations such as
:meth:`_sql.Select.with_only_columns` would cause the method to fail.

If an attribute name exists in more than one FROM clause entity, an
:class:`_exc.AmbiguousColumnError` is now raised, indicating that
:meth:`_sql.Select.filter` (or :meth:`_sql.Select.where`) should be used
instead with explicit table-qualified column references.

Fixes: #8601
Change-Id: I6a46b8f4784801f95f7980ca8ef92f1947653572

8 weeks agoAdd a test for #13021
Mike Bayer [Wed, 3 Dec 2025 19:48:08 +0000 (14:48 -0500)] 
Add a test for #13021

Confirmed the upstream fix for [1] given at [2] solves the issue
illustrated here, this patch adds a test for this case as our
existing tests did not catch this error in python 3.14.1.

Fixes: #13021
Change-Id: Ie6827279ccf2b2cb2e0fe6029aafdcfefc790f1f

8 weeks agoMerge "send same sub_stmt to after_cursor_execute as before" into main
Michael Bayer [Wed, 3 Dec 2025 19:17:16 +0000 (19:17 +0000)] 
Merge "send same sub_stmt to after_cursor_execute as before" into main

8 weeks agoMerge "run sentinel server side fns outside of VALUES" into main
Michael Bayer [Wed, 3 Dec 2025 16:56:08 +0000 (16:56 +0000)] 
Merge "run sentinel server side fns outside of VALUES" into main

8 weeks agoMerge "block json tests for non-json backends" into main
Michael Bayer [Wed, 3 Dec 2025 13:13:17 +0000 (13:13 +0000)] 
Merge "block json tests for non-json backends" into main

8 weeks agoMerge "[typing] Fix type error when passing Mapped columns to values()" into main
Federico Caselli [Wed, 3 Dec 2025 07:41:20 +0000 (07:41 +0000)] 
Merge "[typing] Fix type error when passing Mapped columns to values()" into main

8 weeks agoblock json tests for non-json backends
Mike Bayer [Wed, 3 Dec 2025 04:18:58 +0000 (23:18 -0500)] 
block json tests for non-json backends

these were failing on Oracle which has no json type

Change-Id: I3c35c4f38c581378c74ee9dc3fb7a71655c5ee9c

8 weeks agosend same sub_stmt to after_cursor_execute as before
Mike Bayer [Wed, 3 Dec 2025 04:10:10 +0000 (23:10 -0500)] 
send same sub_stmt to after_cursor_execute as before

Fixed issue in the :meth:`.ConnectionEvents.after_cursor_execute` method
where the SQL statement and parameter list for an "insertmanyvalues"
operation sent to the event would not be the actual SQL / parameters just
emitted on the cursor, instead being the non-batched form of the statement
that's used as a template to generate the batched statements.

Fixes: #13018
Change-Id: Ib5b6c576f2c7a9ed275de30290d619cc651b4816

8 weeks agorun sentinel server side fns outside of VALUES
Mike Bayer [Mon, 1 Dec 2025 20:11:50 +0000 (15:11 -0500)] 
run sentinel server side fns outside of VALUES

Fixed the structure of the SQL string used for the
:ref:`engine_insertmanyvalues` feature 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.

Fixes: #13015
Change-Id: Ia0a2a4e8f89e21852d7cb550dfa5d9ea9447b590

8 weeks ago[typing] Fix type error when passing Mapped columns to values()
Yossi [Mon, 1 Dec 2025 17:06:12 +0000 (12:06 -0500)] 
[typing] Fix type error when passing Mapped columns to values()

This adjusts the _DMLOnlyColumnArgument type to be a more
focused _OnlyColumnArgument type where we also add a more tightly
focused coercion, while still allowing ORM attributes to be used
as arguments.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #13012
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13012
Pull-request-sha: 5ebb402c686abf1090e5b83e3489dfca4908efdf

Change-Id: I8bbccaf556ec5ecb2f5cfdd2030bcfa4eb5ce125

8 weeks agodoc updates
Mike Bayer [Wed, 3 Dec 2025 01:06:50 +0000 (20:06 -0500)] 
doc updates

Change-Id: I60bccf962e4cd1ed567a772c43c969c4807662f6

8 weeks agoMerge "Add native BOOLEAN type support for Oracle 23c and later versions" into main
Federico Caselli [Tue, 2 Dec 2025 21:51:25 +0000 (21:51 +0000)] 
Merge "Add native BOOLEAN type support for Oracle 23c and later versions" into main

8 weeks agoMerge "Type postgresql.ExcludeConstraint()" into main
Federico Caselli [Tue, 2 Dec 2025 19:45:15 +0000 (19:45 +0000)] 
Merge "Type postgresql.ExcludeConstraint()" into main

8 weeks agoAdd native BOOLEAN type support for Oracle 23c and later versions
Yeongbae Jeon [Sun, 23 Nov 2025 11:44:43 +0000 (06:44 -0500)] 
Add native BOOLEAN type support for Oracle 23c and later versions

Added support for native BOOLEAN support in Oracle Database 23c and above.
The Oracle dialect now renders ``BOOLEAN`` automatically when
:class:`.Boolean` is used in DDL, and also now supports direct use of the
:class:`.BOOLEAN` datatype, when 23c and above is in use.  For Oracle
versions prior to 23c, boolean values continue to be emulated using
SMALLINT as before.   Special case handling is also present to ensure a
SMALLINT that's interpreted with the :class:`.Boolean` datatype on Oracle
Database 23c and above continues to return bool values. Pull request
courtesy Yeongbae Jeon.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #11633
Closes: #13000
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13000
Pull-request-sha: 65b8a2c92f539c57ab6b0b1bf045bd23eedb1695

Change-Id: I13be32f6bad5d918f6c7c9622f0deae78f5c6551

8 weeks agoremove sqlalchemy ML
Mike Bayer [Mon, 1 Dec 2025 23:20:02 +0000 (18:20 -0500)] 
remove sqlalchemy ML

Change-Id: I85fbdd8b2b3e5ae0c3a99e98f942865d92351f2f

8 weeks agoadd wheels for python 3.14
Mike Bayer [Mon, 1 Dec 2025 20:21:58 +0000 (15:21 -0500)] 
add wheels for python 3.14

Change-Id: Ia69c9e728e38622d643752b61b0627b3baae5089

8 weeks agoType postgresql.ExcludeConstraint()
Denis Laxalde [Mon, 1 Dec 2025 10:43:18 +0000 (05:43 -0500)] 
Type postgresql.ExcludeConstraint()

Related to #6810.

Closes: #13011
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13011
Pull-request-sha: 4a212cad1b231629ae4e3d6866c9603662a197a2

Change-Id: If5d91e06b6c0afc11adc02bb0c0d5ce97e53203c

8 weeks agoadd TString support
Mike Bayer [Mon, 17 Nov 2025 18:11:24 +0000 (13:11 -0500)] 
add TString support

Added support for Python 3.14+ template strings (t-strings) via the new
:func:`_sql.tstring` construct, as defined in :pep:`750`. This feature
allows for ergonomic SQL statement construction by automatically
interpolating Python values and SQLAlchemy expressions within template
strings.

Part of the challenge here is the syntax only works on py314, so we have
to exclude the test file at many levels when py314 is not used.  not
sure yet how i want to adjust pep8 tests and rules for this.

Fixes: #12548
Change-Id: Ia060d1387ff452fe4f5d924f683529a22a8e1f72