]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 days agoRemoved erroneous debug print (#13349) rel_2_0
Bradley Davis [Thu, 4 Jun 2026 19:51:32 +0000 (12:51 -0700)] 
Removed erroneous debug print (#13349)

(cherry picked from commit 563146468ab5da1e4aea7eca2f6bbb09daa03986)

6 days agoHoist loop-invariant set intersection in _get_display_froms
sebastianbreguel [Sun, 31 May 2026 20:12:19 +0000 (16:12 -0400)] 
Hoist loop-invariant set intersection in _get_display_froms

Fixes #13336.

`SelectState._get_display_froms` recomputed a loop-invariant `_cloned_intersection(...)` once per FROM element in each of the three correlation comprehensions, making each branch O(N²) in the number of FROM elements. This hoists the call so it runs once, which is O(N).

`_cloned_intersection` / `_cloned_difference` are pure and return a set, and neither argument changes during the comprehension, so the result is identical. A function-level benchmark asserts `old == new` at every N (full numbers in #13336), and `test/sql/` plus the ORM compilation/query tests pass: 7442 passed, 359 skipped. Net -14 lines.

Per the issue discussion, no changelog entry is included.

### Checklist

This pull request is:

- [x] A short code fix
  - Issue with a runnable demonstration: #13336
  - Behavior-preserving (no logic change), so it is covered by the existing `test/sql/` and ORM compilation/query suites rather than adding new tests.

Closes: #13337
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13337
Pull-request-sha: beba43e77a773a4d9e9d55cc39c7c85ecda6293e

Change-Id: I95b02ffa66ef709c16bf5275924ec03244c19ecb
(cherry picked from commit abfe6cc47c12b87164a63739e3718257b452dac6)

8 days agoAdd ambiguous column support to SimpleResultMetaData
me-saurabhkohli [Fri, 29 May 2026 20:03:40 +0000 (16:03 -0400)] 
Add ambiguous column support to SimpleResultMetaData

Fixed issue where :meth:`.Result.freeze` would lose track of ambiguous
column names present in the original :class:`.CursorResult`, causing
key-based access on the thawed result to silently return a value instead of
raising :class:`.InvalidRequestError`.  The
:class:`.SimpleResultMetaData` now accepts and propagates ambiguous key
information so that frozen, thawed, and pickled results raise consistently
for duplicate column names.  Pull request courtesy Saurabh Kohli.

Fixes: #9427
Closes: #13335
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13335
Pull-request-sha: c03904ece298493ca69bf6e9cbdae23c7fb6a7b0

Change-Id: Ia184f77b442b069e6f9a4f94a967ead41a1704b6
(cherry picked from commit 4fb459aaf05dd9c31ce3ece57c1bbf81ca9855de)

9 days agoMerge "Fix subqueryload losing .and_() criteria when combined with of_type()" into...
Michael Bayer [Thu, 28 May 2026 14:16:59 +0000 (14:16 +0000)] 
Merge "Fix subqueryload losing .and_() criteria when combined with of_type()" into rel_2_0

10 days agoFix lambda statements with non-lambda criteria
cjc0013 [Mon, 25 May 2026 16:46:50 +0000 (12:46 -0400)] 
Fix lambda statements with non-lambda criteria

Fixed issue where :class:`_sql.StatementLambdaElement` would proxy
attribute access through the cached "expected" expression rather than the
resolved expression, causing stale closure-bound parameter values to be
used when a lambda statement was extended with non-lambda criteria such as
an additional ``.where()`` clause.  Courtesy cjc0013.

Fixes: #10827
Closes: #13327
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13327
Pull-request-sha: ec3e6735bf95d62d768f214dd5a49bbfc4fecaa5

Change-Id: I8a32c11f3da63109cf37c39541df8ebfee52b8c5
(cherry picked from commit c41f25b17031d8e9ca3d7e613c0d4dcd78b693fe)

10 days agoFix subqueryload losing .and_() criteria when combined with of_type()
Arya Rizky [Tue, 12 May 2026 19:08:02 +0000 (15:08 -0400)] 
Fix subqueryload losing .and_() criteria when combined with of_type()

Fixed issue where :func:`_orm.subqueryload` combined with
:meth:`.PropComparator.of_type` and :meth:`.PropComparator.and_` would
silently drop the additional filter criteria, causing all related objects
to be loaded instead of only those matching the filter.  The
:class:`.LoaderCriteriaOption` was being constructed against the base
entity rather than the effective entity indicated by
:meth:`.PropComparator.of_type`.  Pull request courtesy Arya Rizky.

Fixes: #13207
Closes: #13290
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13290
Pull-request-sha: b7a8617cdee3757f4af4abdb4ff0090d69bb1fb5

Change-Id: I2c24652ec112511deaf39dbb9d6197e2097904ed
(cherry picked from commit cf3cfa307f5b8cdfbd47b104db38c193503de1c8)

12 days agoFix Session bulk mappings typing for mapped classes
proto-atlas [Mon, 25 May 2026 19:14:40 +0000 (15:14 -0400)] 
Fix Session bulk mappings typing for mapped classes

Fixes #9256.

This updates the annotations for Session.bulk_insert_mappings() and Session.bulk_update_mappings().

The docstrings and runtime behavior already allow either a mapped class or a Mapper object, but the previous annotations only accepted Mapper[Any].

This patch switches those arguments to the existing _EntityBindKey alias, which matches the inputs accepted by _class_to_mapper(): mapped classes and Mapper objects, but not AliasedClass or AliasedInsp.

I also updated the internal _bulk_save_mappings() annotation so the public methods and the private helper stay consistent. The scoped_session proxy output has been kept in sync with tools/generate_proxy_methods.py, and the generator check passes.

I added a typing regression test covering both mapped classes and Mapper objects for the two bulk mapping methods. I confirmed that the mapped-class cases fail with the old annotation and pass with this change.

Checked locally:

python -m pytest -m mypy test/typing/test_mypy.py -k "session.py" -q
python -m mypy ./lib/sqlalchemy
python tools/generate_proxy_methods.py --check
python -m pytest test/orm/dml/test_bulk.py -q
python -m pytest -m mypy test/typing/test_mypy.py -k "not typed_queries.py" -q

I could not run the full typing suite locally because my local Python 3.12 environment does not include string.templatelib. I only skipped typed_queries.py; that file is expected to be covered by SQLAlchemy's Python 3.14 mypy CI job.

Closes: #13322
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13322
Pull-request-sha: bb730f34275a7c40c94e668ecda1131804ba3084

Change-Id: I4c5d516b3933b4e7fae9c844881a61f557a8bb5e
(cherry picked from commit e00937ec549ecc1d2cae49d4fe84fac3d758b6fb)

13 days agoVersion 2.0.51 placeholder
Mike Bayer [Sun, 24 May 2026 19:20:49 +0000 (15:20 -0400)] 
Version 2.0.51 placeholder

13 days ago- 2.0.50 rel_2_0_50
Mike Bayer [Sun, 24 May 2026 19:15:01 +0000 (15:15 -0400)] 
- 2.0.50

13 days agodont produce side effects for do_orm_execute
Mike Bayer [Sun, 24 May 2026 14:05:29 +0000 (10:05 -0400)] 
dont produce side effects for do_orm_execute

Fixed issue where the presence of a do_orm_execute event hook would cause
internal execution options such as yield_per and loader-specific state from
the first orm_pre_session_exec pass to leak into the second pass, leading to
errors when using relationship loaders such as selectinload and immediateload.
The execution options passed to the second compilation pass are now based on
the original options plus only the explicit updates made via
ORMExecuteState.update_execution_options() within the event hook.

Fixes: #13301
Change-Id: Ide64d7202102930b68a2ab903054d538cd2f99dd

2 weeks agoMerge "Fix ExcludeConstraint not forwarding info to parent constructor" into rel_2_0
Michael Bayer [Wed, 20 May 2026 21:02:40 +0000 (21:02 +0000)] 
Merge "Fix ExcludeConstraint not forwarding info to parent constructor" into rel_2_0

2 weeks agoimplement _post_inspect for AliasedInsp
Mike Bayer [Wed, 20 May 2026 19:59:10 +0000 (15:59 -0400)] 
implement _post_inspect for AliasedInsp

Fixed issue where using :func:`_orm.with_polymorphic` on a leaf class (a
subclass with no further descendants) or a non-inherited class would fail
with an ``AttributeError`` when used in an ORM statement, due to
:func:`_orm.configure_mappers` not being triggered implicitly. The fix
ensures that :class:`.AliasedInsp` participates in the ``_post_inspect``
hook, triggering mapper configuration during ORM statement compilation.

Fixes: #13319
Change-Id: Ic5910474676be41f8c815dc72c38fca8e20cdeb9
(cherry picked from commit afa94c32a91711b81e4e663cc328837354491315)

2 weeks agoFix ExcludeConstraint not forwarding info to parent constructor
WiktorB2004 [Wed, 20 May 2026 20:05:41 +0000 (16:05 -0400)] 
Fix ExcludeConstraint not forwarding info to parent constructor

Fixed issue where the :class:`.ExcludeConstraint` construct did not
correctly forward the :paramref:`.ExcludeConstraint.info` parameter to
the superclass, causing user-defined metadata to be lost. Pull request
courtesy Wiktor Byrka.

Fixes: #13317
Closes: #13316
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13316
Pull-request-sha: be7f4fee2c40d1986519e93145471faad61021af
Change-Id: Idc4846f02127d1d39a8c638cb03b0379932e9fd6
(cherry picked from commit cf2984c31d1f3edcfd26801a8ac560d95b52892e)

2 weeks agoMerge "Fix joinedload + of_type() + and_() invalid SQL for subclass columns" into...
Michael Bayer [Wed, 20 May 2026 20:02:55 +0000 (20:02 +0000)] 
Merge "Fix joinedload + of_type() + and_() invalid SQL for subclass columns" into rel_2_0

2 weeks agoMerge "Fix floordiv (//) for float/numeric by int with div_is_floordiv dialects"...
Michael Bayer [Wed, 20 May 2026 19:53:22 +0000 (19:53 +0000)] 
Merge "Fix floordiv (//) for float/numeric by int with div_is_floordiv dialects" into rel_2_0

2 weeks agoFix joinedload + of_type() + and_() invalid SQL for subclass columns
Joaquin Hui Gomez [Wed, 1 Apr 2026 17:29:38 +0000 (13:29 -0400)] 
Fix joinedload + of_type() + and_() invalid SQL for subclass columns

Fixed issue where using :func:`_orm.joinedload` with
:meth:`.PropComparator.of_type` targeting a joined-table subclass combined
with :meth:`.PropComparator.and_` referencing a column on that subclass
would generate invalid SQL, where the subclass column was not adapted to
the subquery alias.  Pull request courtesy Joaquin Hui Gomez.

Fixes #13203

Closes: #13206
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13206
Pull-request-sha: ba55b0c3e2a8dae28a1c7d7ae646e3480a04425c

Change-Id: I78fe4672649d1d5498e3bc653e5d943ccb55dafd
(cherry picked from commit e04e4b2b58ef9581b3a5e4129e719b0b707b446a)

2 weeks agoFix floordiv (//) for float/numeric by int with div_is_floordiv dialects
OSS Contributor [Mon, 23 Mar 2026 14:44:40 +0000 (10:44 -0400)] 
Fix floordiv (//) for float/numeric by int with div_is_floordiv dialects

Fixed issue where floor division (``//``) between a :class:`.Float` or
:class:`.Numeric` numerator and an :class:`.Integer` denominator would omit
the ``FLOOR()`` SQL wrapper on dialects where
:attr:`.Dialect.div_is_floordiv` is ``True`` (the default, including
PostgreSQL and SQLite).  ``FLOOR()`` is now applied if either the
denominator or the numerator is a non-integer, so that expressions such as
``float_col // int_col`` render as ``FLOOR(float_col / int_col)`` instead
of the incorrect ``float_col / int_col``.  Pull request courtesy r266-tech.

Fixes: #10528
Closes: #13191
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13191
Pull-request-sha: c9cbc47c877e19c91f912556b4ead6cd26e3cfe6

Change-Id: I5f9f02d966aa6ccee214a2c5cc27a73a4292da03
(cherry picked from commit a4c7dbc49e820e4eaf111b618b20d80e6b5ddc43)

2 weeks agoFix trivial PyPy failures
mattip [Wed, 20 May 2026 17:47:17 +0000 (13:47 -0400)] 
Fix trivial PyPy failures

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

### Description

Fixes: #13274
References: #9154

There were two relatively causes to some of the ~21 failures on PyPy:
- weakrefs may be deleted but the objects not finalized on PyPy. This manifests as `ref.obj() is None` I added a test for the `release()` case that also failed on CPython before the fix.
- a condition added in 2022 for missing sqllite3 behaviour is no longer necessary, and is now causing a failure

In order to run the changes in CI, I added PyPy to the PR CI run. Before merging I will revert that change. There are still a number of failures with PyPy around different error messages, different inspect.signatures and one sticky problem with the pure-python datetime.py that actually comes from CPython. I will continue to work on them, but they are not specific to sqlalchemy.

Note the CI run is ~6 minutes where the CPython ones are ~3 minutes. This is expected, since PyPy's JIT does not kick in on short tests, and the base compiler is about 2x slower.

### Checklist
<!-- 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:

- [ ] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [x] 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: #13276
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13276
Pull-request-sha: 00472f32f64827325f071150e8b6ecf1fbe9f22e

Change-Id: Id5d4ba37cf8db2345a948f973d7b1710910359a1
(cherry picked from commit 56edb237cb652bed221a377cdc2ae2b7b835dd61)

2 weeks agoMerge "document postgresql_nulls_not_distinct" into rel_2_0
Michael Bayer [Wed, 20 May 2026 14:05:42 +0000 (14:05 +0000)] 
Merge "document postgresql_nulls_not_distinct" into rel_2_0

2 weeks agoAdjust TypeError message to Python 3.15
Karolina Surma [Tue, 19 May 2026 14:20:38 +0000 (10:20 -0400)] 
Adjust TypeError message to Python 3.15

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

### Description
The `.fromisoformat()` error message tested in `test_no_string()` changed in Python 3.15, this fixes the test.

See #13308 for the `rel_2_0` branch.

### Checklist
<!-- 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:

- [ ] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [x] A short code fix (in a test, therefore I didn’t create an issue)
- 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: #13307
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13307
Pull-request-sha: 90bc13fc416ea45ba5429d5f8ecffc24b108c1b1

Change-Id: I461d71b0fad18fa4f108102bb1c22c0e980fc70e
(cherry picked from commit f07ad99839105f254df4e640ab851bcc6910168c)

2 weeks agorobustly handle reconnect param across all pymysql variants
Mike Bayer [Tue, 19 May 2026 13:40:01 +0000 (09:40 -0400)] 
robustly handle reconnect param across all pymysql variants

Fixed issue in aiomysql and asyncmy dialects that appears as of using
pymysql 1.2.0; the dialects were not properly taking into account logic
that detects the argument signature of pymysql's ``ping()`` method which
was added as part of :ticket:`10492`.

We add a "does ping have reconnect" check for all three DBAPIs
individually.  To suit asyncmy's use of cython we also needed to
adjust vendored getargspec() routines.

Fixes: #13306
Change-Id: Iad90ec6cfe9ee3b99736dd2153264090e7f76be1
(cherry picked from commit b3b8d88d1e4cec04c2dceb9c374631e9b692ba58)

2 weeks agodocument postgresql_nulls_not_distinct
David Lord [Sun, 17 May 2026 20:09:16 +0000 (16:09 -0400)] 
document postgresql_nulls_not_distinct

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

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

https://github.com/sqlalchemy/sqlalchemy/issues/8240 and https://github.com/sqlalchemy/sqlalchemy/pull/9834 added support for `NULLS NOT DISTINCT` to the PostgreSQL dialect, but didn't add it to the docs (only the change log). This adds a section to the "Constraint Options" section of the PostgreSQL dialect docs.

### Checklist
<!-- 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: #13279
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13279
Pull-request-sha: cdc858cd88fbf86661662147210f9587117aa593

Change-Id: I3f2c8fe346d3235fa8ba12c4d9ab712ddb840230
(cherry picked from commit 57dcfdacaa75ddac3a9246512f3deac4aef10cf0)

2 weeks agoadd update to black 26.3.1 commit to blame ignore
Federico Caselli [Sun, 17 May 2026 20:08:09 +0000 (22:08 +0200)] 
add update to black 26.3.1 commit to blame ignore

Change-Id: I06a2e72d99db2f836b0a8fb18a99e4ea08d4bf43

2 weeks agoremove redundant deserializer assignment from asyncpg dialect (#13287)
Henry Cai [Sun, 17 May 2026 20:02:37 +0000 (13:02 -0700)] 
remove redundant deserializer assignment from asyncpg dialect (#13287)

(cherry picked from commit 120a967505efb4a50a9134bf45b8e88aebb9f483)

3 weeks agoMerge "update to black 26.3.1" into rel_2_0
Federico Caselli [Sun, 10 May 2026 20:24:31 +0000 (20:24 +0000)] 
Merge "update to black 26.3.1" into rel_2_0

3 weeks agoupdate to black 26.3.1
Federico Caselli [Fri, 8 May 2026 20:48:58 +0000 (22:48 +0200)] 
update to black 26.3.1

Closes: #13280
Change-Id: Ifbb77dd6d2a1c228ae97fcf8160f40e975edc57c
(cherry picked from commit 1e1c0084b1804eaae8b7f089435241a2b8f4be60)

3 weeks agocollect pep8 errors
Mike Bayer [Sun, 10 May 2026 15:30:00 +0000 (11:30 -0400)] 
collect pep8 errors

run each command in a try/except (they print out error messages
regardless) and report at the end on all individual runs.

Change-Id: I347c04f5c49c69daadf9f5f9e7c6c488cdf27f35
(cherry picked from commit 3c650cede44e74b0a1939652034debc9fa74759c)

4 weeks agosupport mypy 2.0
Mike Bayer [Thu, 7 May 2026 15:54:58 +0000 (11:54 -0400)] 
support mypy 2.0

mypy just went to 2.0.

and there seems to be...

exactly one "type: ignore" to remove and...that's it?

well OK!

Change-Id: I29f919641acc0e970b566c850063db7ecad70ed9
(cherry picked from commit dcb36d73bbf6a8e6e780aae3c5ae40e8d03bec3a)

4 weeks agoMerge "Fixes: #10673: make declared_attr covariant" into rel_2_0
Michael Bayer [Thu, 7 May 2026 15:32:26 +0000 (15:32 +0000)] 
Merge "Fixes: #10673: make declared_attr covariant" into rel_2_0

4 weeks agoReplace logging.WARN by logging.WARNING (#13277)
Léo Gallot [Tue, 5 May 2026 19:01:21 +0000 (21:01 +0200)] 
Replace logging.WARN by logging.WARNING (#13277)

(cherry picked from commit ffc32e517dd3e89ed3f74b78d71d452fc8663aa3)

4 weeks agolimit pypy to one build, fix typo (#13275)
Matti Picus [Mon, 4 May 2026 12:51:32 +0000 (15:51 +0300)] 
limit pypy to one build, fix typo (#13275)

(cherry picked from commit f353f623271087bfe47f4b7271b35578046c59b5)
Change-Id: I41ccb411b78d132cd5aa6c517d4583c85217d900

4 weeks agorestore skip of 3.14t with cext and greenlet
Federico Caselli [Sun, 3 May 2026 19:27:32 +0000 (21:27 +0200)] 
restore skip of 3.14t with cext and greenlet

Change-Id: Ia75ab15c73f5a93f5eb2b6b99870aab824d0a43d
(cherry picked from commit a50a9097d33614197fc8a41b788237f933455bc0)

5 weeks agoBump pypa/cibuildwheel from 3.3.0 to 3.4.1 (#13271)
dependabot[bot] [Sat, 2 May 2026 18:33:39 +0000 (20:33 +0200)] 
Bump pypa/cibuildwheel from 3.3.0 to 3.4.1 (#13271)

* Bump pypa/cibuildwheel from 3.3.0 to 3.4.1

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 3.3.0 to 3.4.1.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v3.3.0...v3.4.1)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-version: 3.4.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
* remove wheels for 3.13t since it's deprecated

Change-Id: I51157a09e7b01d5b23adc10d9a4b386776dedf7e

* remove tests from 3.13t

Change-Id: I73bb2761d07b0c8f549a4ba8ee7299dec6907df7

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Federico Caselli <cfederico87@gmail.com>
(cherry picked from commit 583e2c4a0cb4ae4659a0d4c268d606b10f107ffa)

# Conflicts:
# .github/workflows/create-wheels.yaml
# .github/workflows/run-test.yaml
# noxfile.py

5 weeks agoBump actions/checkout from 4 to 6 (#13273)
dependabot[bot] [Thu, 30 Apr 2026 19:57:42 +0000 (21:57 +0200)] 
Bump actions/checkout from 4 to 6 (#13273)

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit db9b991551325d0194524b79e63f3af9f497b78a)

5 weeks agoBump actions/setup-python from 5 to 6 (#13270)
dependabot[bot] [Thu, 30 Apr 2026 19:53:11 +0000 (21:53 +0200)] 
Bump actions/setup-python from 5 to 6 (#13270)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit 57ccf3e4ed3e020998325f886220c19bf9e1e6a4)

5 weeks agodocs: fix typo pool_echo -> echo_pool (#13269)
Léo Gallot [Thu, 30 Apr 2026 19:51:19 +0000 (21:51 +0200)] 
docs: fix typo pool_echo -> echo_pool (#13269)

(cherry picked from commit 046c434d33c803accaaf65bd1b5c4e4f28bd2d77)

5 weeks agoFixes: #10673: make declared_attr covariant
Luiz Felipe Neves [Thu, 30 Apr 2026 17:06:25 +0000 (13:06 -0400)] 
Fixes: #10673: make declared_attr covariant
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
I made declared_attr covariant as suggested in #10673. mypy didn't seem to complain. Added a regression test for the use case that was asked for. Unfortunately, it seems like using `Mapped[int | UUID]` directly in the Protocol won't work:

```python
class CompareProtocol(Protocol):
    id: Mapped[int | UUID]
```

Because mypy will see this as a settable variable and not as a SQLAlchemy descriptor. Using `@property` instead seems to work and it's what I used in the test (perhaps it should be documented as the way to achieve this?):

```python
class CompareProtocol(Protocol):
    @property
    def id(self) -> Mapped[int | UUID]: ...
```

### Checklist
<!-- 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:

- [ ] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [X] 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.

Closes: #13266
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13266
Pull-request-sha: 8edd2841f4bbe61f8bb9bc15a7a57e0560698779

Change-Id: I7d63ad43df0ab34ee7c7389a007191be91efa574
(cherry picked from commit f1dfe10237d754ae25b9790c9a9e4d9defccb52b)

5 weeks agodocs: fix incorrect execution context class reference (#13254)
Léo Gallot [Wed, 29 Apr 2026 19:56:29 +0000 (21:56 +0200)] 
docs: fix incorrect execution context class reference (#13254)

(cherry picked from commit 65192be2a46964e6934f54aab4a05218f9c4c871)

6 weeks agonarrow scope of _correct_for_mysql_bugs_88718_96365
Mike Bayer [Mon, 20 Apr 2026 13:30:35 +0000 (09:30 -0400)] 
narrow scope of _correct_for_mysql_bugs_88718_96365

Narrowed the scope of the internal workaround for MySQL bugs `#88718
<https://bugs.mysql.com/bug.php?id=88718>`_ and `#96365
<https://bugs.mysql.com/bug.php?id=96365>`_ so that it is only applied
where needed: MySQL 8.0.1 through 8.0.13 (where bug 88718 is present), and
on systems with ``lower_case_table_names=2`` (where bug 96365 applies,
typically macOS).  Previously the workaround was applied unconditionally
for all MySQL 8.0+ versions, which caused a ``KeyError`` during foreign key
reflection when the database user lacked SELECT privileges on referred
tables.

Fixes: #13243
Change-Id: I7c29f67d1653c5cd32f29e098f038fea1d56117b
(cherry picked from commit 530e1f71e74263ee9e23245071af2557aa65d425)

6 weeks agodocs: fix typo 'nad' -> 'and' in DefaultDialect.construct_arguments docstring (#13245)
Bojun Chai [Mon, 20 Apr 2026 20:30:20 +0000 (04:30 +0800)] 
docs: fix typo 'nad' -> 'and' in DefaultDialect.construct_arguments docstring (#13245)

Co-authored-by: Bojun Chai <bojunchai@microsoft.com>
(cherry picked from commit 053a90668acd235cc03b5209470e24c9742121db)

7 weeks agohandle asyncpg InternalClientError
Mike Bayer [Fri, 17 Apr 2026 20:13:53 +0000 (16:13 -0400)] 
handle asyncpg InternalClientError

Fixed issue where the asyncpg driver could throw an insufficiently-handled
exception ``InternalClientError`` under some circumstances, leading to
connections not being properly marked as invalidated.

Fixes: #13241
References: https://github.com/MagicStack/asyncpg/issues/1069
Change-Id: Iaaf551b3d7b062cce62e13b441161583a484615f
(cherry picked from commit 70de8780239972233fe2b7b4121251698bbf19ca)

7 weeks agoFix 'compatiblity' typo in sqlite dialect docstring (#13237)
Mukunda Rao Katta [Thu, 16 Apr 2026 18:56:30 +0000 (11:56 -0700)] 
Fix 'compatiblity' typo in sqlite dialect docstring (#13237)

Co-authored-by: MukundaKatta <mukundakatta@users.noreply.github.com>
(cherry picked from commit 1f27a0deefd86c14fd2de3b80e24aeb00c154da7)

7 weeks agoImprove pg two-phase transactions
Federico Caselli [Mon, 13 Apr 2026 21:53:00 +0000 (23:53 +0200)] 
Improve pg two-phase transactions

Improve handling of two phase transaction identifiers for PostgreSQL
when the identifier is provided by the user.
As part of this change the psycopg dialect was updated to use the DBAPI
two phase transaction API instead of executing the SQL directly.

Fixes: #13229
Change-Id: If8301a7253b4a0c88e5323c9a052c3a9fa258780
(cherry picked from commit 08cef20f4a2bfbeda61abfe6caee975190f0794c)

7 weeks agoImprove escaping in pysqlcipher
Federico Caselli [Mon, 13 Apr 2026 20:26:48 +0000 (22:26 +0200)] 
Improve escaping in pysqlcipher

Escape key and pragma values when utilizing the pysqlcipher dialect.

Fixes: #13230
Change-Id: I7583577a3e00e2f2986e50f32136a9ef005eb28a
(cherry picked from commit 87f17c2e59cd27e20e7badc685c482e788fb2711)

2 months agoVersion 2.0.50 placeholder
Mike Bayer [Fri, 3 Apr 2026 16:38:35 +0000 (12:38 -0400)] 
Version 2.0.50 placeholder

2 months ago- 2.0.49 rel_2_0_49
Mike Bayer [Fri, 3 Apr 2026 16:34:12 +0000 (12:34 -0400)] 
- 2.0.49

2 months agocorrect that last exclude, only the greenlet builds
Mike Bayer [Fri, 3 Apr 2026 16:19:52 +0000 (12:19 -0400)] 
correct that last exclude, only the greenlet builds

Change-Id: I6944fdbf6c96b2b462bc91040bc347f9736c754a

2 months agodisable failing actions combos so we can get a green
Mike Bayer [Fri, 3 Apr 2026 16:02:03 +0000 (12:02 -0400)] 
disable failing actions combos so we can get a green

Change-Id: I120b14b03f6baeff67be7195a07f47e29e67ba84

2 months agoMerge "really remove cx_oracle from test setup" into rel_2_0
Michael Bayer [Wed, 1 Apr 2026 20:28:19 +0000 (20:28 +0000)] 
Merge "really remove cx_oracle from test setup" into rel_2_0

2 months agoreally remove cx_oracle from test setup
Mike Bayer [Wed, 1 Apr 2026 20:10:17 +0000 (16:10 -0400)] 
really remove cx_oracle from test setup

in 6282bcef11781b5ded26d48b22b5f we tried to disable cx_oracle
testing bug failed because pyproject was still pulling it in.
really fix this time

Change-Id: If5a46bf1ad9a9ee48e8693cccdc4b8b40cee392d

2 months agoupdate for mypy 1.20.0
Mike Bayer [Wed, 1 Apr 2026 18:31:21 +0000 (14:31 -0400)] 
update for mypy 1.20.0

Change-Id: I95f72b8a1818b79d01d26531202199f24fe3b808
(cherry picked from commit 120eb13e8e08d167fafd56590aaeb3c048f7afcc)

2 months agoaccommodate subclass mapper in post-loader entity_isa check
Mike Bayer [Sun, 29 Mar 2026 17:46:39 +0000 (13:46 -0400)] 
accommodate subclass mapper in post-loader entity_isa check

Fixed issue where using chained loader options such as
:func:`_orm.selectinload` after :func:`_orm.joinedload` with
:meth:`_orm.PropComparator.of_type` for a polymorphic relationship would
not properly apply the chained loader option. The loader option is now
correctly applied when using a call such as
``joinedload(A.b.of_type(poly)).selectinload(poly.SubClass.c)`` to eagerly
load related objects.

Fixes: #13209
Change-Id: I2d14838f1b1a9a2b18dc52137910dab0bccf0dd5
(cherry picked from commit 2ac8c1a7c71400c1bc13f54f3c05cfd2e3ae1442)

2 months agoMerge "fix: Session.get() with with_for_update=False skips identity map" into rel_2_0
Michael Bayer [Sun, 29 Mar 2026 17:10:16 +0000 (17:10 +0000)] 
Merge "fix: Session.get() with with_for_update=False skips identity map" into rel_2_0

2 months agoapply _path_with_polymorphic in prepend as well
Mike Bayer [Fri, 27 Mar 2026 18:24:10 +0000 (14:24 -0400)] 
apply _path_with_polymorphic in prepend as well

Fixed issue where using :meth:`_orm.Load.options` to apply a chained loader
option such as :func:`_orm.joinedload` or :func:`_orm.selectinload` with
:meth:`_orm.PropComparator.of_type` for a polymorphic relationship would
not generate the necessary clauses for the polymorphic subclasses. The
polymorphic loading strategy is now correctly propagated when using a call
such as ``joinedload(A.b).options(joinedload(B.c.of_type(poly)))`` to match
the behavior of direct chaining e.g.
``joinedload(A.b).joinedload(B.c.of_type(poly))``.

Fixes: #13202
Change-Id: I7b2ce2dd10a7f8583ff99495b0a65fa1a895ee29
(cherry picked from commit d3a8d4950e7f1c1cfcabc819e4b85f0bba61e26d)

2 months agofix: Session.get() with with_for_update=False skips identity map
joshuaswanson [Fri, 27 Mar 2026 16:41:11 +0000 (12:41 -0400)] 
fix: Session.get() with with_for_update=False skips identity map

Fixes #13176.

`Session.get()` checks `with_for_update is None` to decide whether to look up the identity map. Passing `with_for_update=False` fails this check and always hits the database, even though `ForUpdateArg._from_argument` already treats `False` and `None` identically (both return `None`). Changed to `with_for_update in (None, False)` to match.

Closes: #13199
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13199
Pull-request-sha: c639b8723888947317598df387c5e3e4d87acac4

Change-Id: I0584873f46099afadcdd760c0a267ae4d30528eb
(cherry picked from commit d466d375889ee266ef928b6fbb6d673bda6beeb1)

2 months agoMerge "detect and accommodate reverse condition for loader strategy" into rel_2_0
Michael Bayer [Mon, 23 Mar 2026 21:21:59 +0000 (21:21 +0000)] 
Merge "detect and accommodate reverse condition for loader strategy" into rel_2_0

2 months agolink insert.value to data insert tutorial
Federico Caselli [Mon, 23 Mar 2026 20:59:23 +0000 (21:59 +0100)] 
link insert.value to data insert tutorial

Change-Id: I892fd7357f88c0e8d16e8e6fb74f18f4541ff795
(cherry picked from commit a0baf90b2ee7f21f1f17e27851cb4fc3cc47e3ef)

2 months agodetect and accommodate reverse condition for loader strategy
Mike Bayer [Mon, 23 Mar 2026 18:13:02 +0000 (14:13 -0400)] 
detect and accommodate reverse condition for loader strategy

Fixed issue where chained :func:`_orm.joinedload` options would not be
applied correctly when the final relationship in the chain is declared on a
base mapper and accessed through a subclass mapper in a
:func:`_orm.with_polymorphic` query. The path registry now correctly
computes the natural path when a property declared on a base class is
accessed through a path containing a subclass mapper, ensuring the loader
option can be located during query compilation.

Fixes: #13193
Change-Id: I9ec83a0f184caed2bf6dd087b20c3538d6c23597
(cherry picked from commit 5f7e29fb4657367d8b02bd5d56ad28807b9df691)

2 months agomssql: fall back to base type for alias types during reflection
Carlos Serrano [Wed, 18 Mar 2026 15:37:08 +0000 (11:37 -0400)] 
mssql: fall back to base type for alias types during reflection

Fixed regression from version 2.0.42 caused by :ticket:`12654` where the
updated column reflection query would receive SQL Server "type alias" names
for special types such as ``sysname``, whereas previously the base name
would be received (e.g. ``nvarchar`` for ``sysname``), leading to warnings
that such types could not be reflected and resulting in :class:`.NullType`,
rather than the expected :class:`.NVARCHAR` for a type like ``sysname``.
The column reflection query now joins ``sys.types`` a second time to look
up the base type when the user type name is not present in
:attr:`.MSDialect.ischema_names`, and both names are checked in
:attr:`.MSDialect.ischema_names` for a match. Pull request courtesy Carlos
Serrano.

Fixes: #13181
Fixes: #13182
Closes: #13178
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13178
Pull-request-sha: be5c3850594665c0154ae215d4f9c322cc5a3f5a

Change-Id: I7fe86b80dfa45b208f7d97003ee5b1df3f07bfe7
(cherry picked from commit 1c78168f8a1a9cd3c88f1977bba1bac763225482)

2 months agoMerge "Remove version warning in SQL Server" into rel_2_0
Michael Bayer [Fri, 20 Mar 2026 19:25:05 +0000 (19:25 +0000)] 
Merge "Remove version warning in SQL Server" into rel_2_0

2 months agoMerge "Allow escaped quotes in Postgres quoted identifier" into rel_2_0
Michael Bayer [Fri, 20 Mar 2026 19:23:43 +0000 (19:23 +0000)] 
Merge "Allow escaped quotes in Postgres quoted identifier" into rel_2_0

2 months agoremove cx_oracle from testing
Mike Bayer [Thu, 19 Mar 2026 00:21:20 +0000 (20:21 -0400)] 
remove cx_oracle from testing

cx_oracle is no longer able to build from its .tar.gz form
reliably because it does not include setuptools in its build
dependencies.   It still can be built if pip is given
--no-build-isolation, or if a wheel file is installed rather than
the .tar.gz, but given how quickly cx_oracle has been pushed
aside by oracledb it's not really that important to be testing
it anymore.

Change-Id: I8a4b2cffabe5275a0df88b5a624ecd6379d84d37
(cherry picked from commit 6282bcef11781b5ded26d48b22b5fac8d2eebd61)

2 months agoAdd typing overloads to Query.__getitem__ and AppenderQuery.__getitem__
medovi40k [Sat, 28 Feb 2026 23:10:17 +0000 (18:10 -0500)] 
Add typing overloads to Query.__getitem__ and AppenderQuery.__getitem__

Fixes #13128

### Description
`Query.__getitem__` and `AppenderQuery.__getitem__` previously returned Union[_T, List[_T]] for all inputs, making the return type inaccurate.
Added `@overload` signatures so that integer index returns _T and slice returns List[_T].

This pull request is:

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

Closes: #13142
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13142
Pull-request-sha: 9ba1f0145d90b18c997137aeba7fde72dac23a7c

Change-Id: Ib37ab63d3d844491c34cc5ccfc4efc1591a1878c
(cherry picked from commit 8af25c2b35f3740a00e2551c65f9ba245e6f5a9d)

2 months agoAllow escaped quotes in Postgres quoted identifier
Austin Graham [Wed, 18 Mar 2026 14:57:13 +0000 (10:57 -0400)] 
Allow escaped quotes in Postgres quoted identifier

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

### Description
Issue: https://github.com/sqlalchemy/sqlalchemy/issues/10902

Hello! This is my first PR here, so please let me know what I may have missed in terms of having a valuable contribution. I was looking through issues to grab an easy first one, and found this. Looks like someone else was going to have a go at it, but never did.

I simply added a small change to the FK regex in for Postgres that allows anything not quotes alongside escaped double quotes. Test is included for the scenario mentioned in the issue. Alongside that, I didn't see a test for general quoted strings, so I added another one that includes spaces and dashes, in my experience common things to be used inside quoted identifiers.

A manual test as well:
DB setup:
```
austin_test_bug=# CREATE TABLE """test_parent_table-quoted""" (id SERIAL PRIMARY KEY, val INTEGER);
CREATE TABLE
austin_test_bug=# CREATE TABLE test_child_table_ref_quoted (id SERIAL, parent INTEGER, CONSTRAINT fk_parent FOREIGN KEY (parent) REFERENCES """test_parent_table-quoted"""(id));
CREATE TABLE
austin_test_bug=# \d+
                                                     List of relations
 Schema |                Name                |   Type   |  Owner   | Persistence | Access method |    Size    | Description
--------+------------------------------------+----------+----------+-------------+---------------+------------+-------------
 public | "test_parent_table-quoted"         | table    | postgres | permanent   | heap          | 0 bytes    |
 public | "test_parent_table-quoted"_id_seq  | sequence | postgres | permanent   |               | 8192 bytes |
 public | test_child_table_ref_quoted        | table    | postgres | permanent   | heap          | 0 bytes    |
 public | test_child_table_ref_quoted_id_seq | sequence | postgres | permanent   |               | 8192 bytes |
(4 rows)

```

And the python:
```
>>> from sqlalchemy import create_engine, inspect
>>> engine = create_engine('postgresql://scott:tiger@localhost:5432/austin_test_bug')
>>> connection = engine.connect()
>>> inspect(connection).get_multi_foreign_keys()
{(None, '"test_parent_table-quoted"'): [], (None, 'test_child_table_ref_quoted'): [{'name': 'fk_parent', 'constrained_columns': ['parent'], 'referred_schema': None, 'referred_table': '"test_parent_table-quoted"', 'referred_columns': ['id'], 'options': {}, 'comment': None}]}
```

### Checklist
<!-- 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:

- [ ] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [x] 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!**

Fixes: #10902
Closes: #13179
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13179
Pull-request-sha: 8890dc3250a30fc62b8f15cd1da1353b81524c00

Change-Id: I185c2cb062740551ab931368de602054eb5a4acd
(cherry picked from commit c7412ac909125db873b9ddff0dafb8d92034d0a7)

2 months agoRemove version warning in SQL Server
Federico Caselli [Wed, 18 Mar 2026 19:45:39 +0000 (20:45 +0100)] 
Remove version warning in SQL Server

Remove warning for SQL Server dialect when a new version is detected.
The warning was originally added more than 15 years ago due to an unexpected
value returned when using an old version of FreeTDS.
The assumption is that since then the issue has been resolved, so make the
SQL Server dialect behave like the other ones that don't have an upper bound
check on the version number.

This effectively reverts 64d92c836ce029e33b57bcabd4ca76944549e022
that was added for #1825

Fixes: #13185
Change-Id: I79c6951b2fbb6da2caefca97dc3e1b9d8f48f0ab
(cherry picked from commit f5e4c2bcaa27cf1e1e73e5fc8d4ca19180954ae8)

2 months agoclarify the Result.closed attribute
Mike Bayer [Wed, 18 Mar 2026 19:30:54 +0000 (15:30 -0400)] 
clarify the Result.closed attribute

document that Result.returns_rows is usually what people
want when they are looking for this.

References: #13184
Change-Id: Ia0b23e7482115bca3f93d20e21e53598aa9d084c
(cherry picked from commit 4840e6a206741eb7fe54e47067f61a57dd36c68d)

2 months agoMerge "ensure function classes are not shadowed" into rel_2_0
Michael Bayer [Wed, 18 Mar 2026 15:01:48 +0000 (15:01 +0000)] 
Merge "ensure function classes are not shadowed" into rel_2_0

2 months agoensure function classes are not shadowed
Federico Caselli [Thu, 12 Mar 2026 22:34:27 +0000 (23:34 +0100)] 
ensure function classes are not shadowed

Ensure the _FunctionGenerator method do not shadow the function class
of the same name

Fixed a typing issue where the typed members of :data:`.func` would return
the appropriate class of the same name, however this creates an issue for
typecheckers such as Zuban and pyrefly that assume :pep:`749` style
typechecking even if the file states that it's a :pep:`563` file; they see
the returned name as indicating the method object and not the class object.
These typecheckers are actually following along with an upcoming test
harness that insists on :pep:`749` style name resolution for this case
unconditionally.  Since :pep:`749` is the way of the future regardless,
differently-named type aliases have been added for these return types.

Fixes: #13167
Change-Id: If58a3858001c78ab21b2ed343205dfd9ce868576
(cherry picked from commit 0a185a3bb6347719ffab60012db8fbbc23eb29e4)

2 months agoUpdate _NamingSchemaCallable to support Index
Martin Baláž [Mon, 9 Mar 2026 17:19:04 +0000 (13:19 -0400)] 
Update _NamingSchemaCallable to support Index

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

### Description
<!-- Describe your changes in detail -->
According to [the documentation](https://docs.sqlalchemy.org/en/21/core/metadata.html#sqlalchemy.schema.MetaData.params.naming_convention), the values associated with user-defined “token” keys in `naming_convention` should be callables of the form `fn(constraint, table)`, which accepts the constraint/index object and Table. However, the type alias `_NamingSchemaCallable` accepts only constraint in the first argument. I propose to update `_NamingSchemaCallable` to accept also an index.

### Example
```python
import sqlalchemy

def include_0_N_name(
schema_item: sqlalchemy.Index | sqlalchemy.Constraint,
table: sqlalchemy.Table,
) -> str:
tokens = []

for column in schema_item.dialect_options.get('postgresql', {}).get('include', []):
tokens.append("_")
tokens.append(column.name)

return "".join(tokens)

metadata = sqlalchemy.MetaData(
naming_convention={
"include_0_N_name": include_0_N_name,
"ix": "%(table_name)s_%(column_0_N_name)s%(include_0_N_name)s_idx",
"uq": "%(table_name)s_%(column_0_N_name)s%(include_0_N_name)s_key",
"fk": "%(table_name)s_%(column_0_N_name)s%(include_0_N_name)s_fkey",
"pk": "%(table_name)s_pkey",
},
)
```

### Checklist
<!-- 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.

Closes: #13161
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13161
Pull-request-sha: cf53bd722932741bceaba1dd16a52ba93ff579cc

Change-Id: I0daf8a6eeb458aaa09f3392e00d98c27dbf8ca3c
(cherry picked from commit 2513bc65721a7651adb711b075b31f81d4b10343)

3 months agodocs: fix RelationshipProperty comparator cross-references (#13155)
Dr Alex Mitre [Fri, 6 Mar 2026 21:57:04 +0000 (15:57 -0600)] 
docs: fix RelationshipProperty comparator cross-references (#13155)

(cherry picked from commit 1eff7bbc96014e6d0d6f0ac4d11c29c5ad187f22)

3 months agoAdd fast_executemany property to asyncadapt aioodbc cursor
Georg Sieber [Wed, 4 Mar 2026 23:24:44 +0000 (18:24 -0500)] 
Add fast_executemany property to asyncadapt aioodbc cursor

Enhanced the ``aioodbc`` dialect to expose the ``fast_executemany``
attribute of the pyodbc cursor.   This allows the ``fast_executemany``
parameter to work with the ``mssql+aioodbc`` dialect.   Pull request
courtesy Georg Sieber.

Fixes: #13152
Closes: #13151
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13151
Pull-request-sha: c25aa581afff6d49af74b3d7b58b9635a23556e9

Change-Id: I6f27600b509f4881769ecca944fc0939e26626e6
(cherry picked from commit f09778c70050391ab77e97e8043083f6a5177038)

3 months agoOracle dialect reflection of RAW length
Daniel Sullivan [Tue, 3 Mar 2026 20:50:17 +0000 (15:50 -0500)] 
Oracle dialect reflection of RAW length

Fixed issue in Oracle dialect where the :class:`_oracle.RAW` datatype would
not reflect the length parameter.   Pull request courtesy Daniel Sullivan.

Fixes: #13150
Closes: #13149
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13149
Pull-request-sha: f7488faaf86451dfe53801faa848414c343614b3

Change-Id: I7db0219b6484317de15203b42f9ca5a84fe36bb7
(cherry picked from commit ddfec399ce63403a48d7185c2b5938ab4db27a5a)

3 months agoVersion 2.0.49 placeholder
Mike Bayer [Mon, 2 Mar 2026 15:29:07 +0000 (10:29 -0500)] 
Version 2.0.49 placeholder

3 months ago- 2.0.48 rel_2_0_48
Mike Bayer [Mon, 2 Mar 2026 14:39:42 +0000 (09:39 -0500)] 
- 2.0.48

3 months agofix changelog typo
Mike Bayer [Mon, 2 Mar 2026 14:38:02 +0000 (09:38 -0500)] 
fix changelog typo

Change-Id: I08ffdc1eda8921745e0459ca375e154ac3cf8b9d
(cherry picked from commit d7132e9562caf8eb542d4ca6a4bef65fde747c1d)

3 months agomake local mutable copies for cargs / cparams in do_connect
Mike Bayer [Sun, 1 Mar 2026 18:05:21 +0000 (13:05 -0500)] 
make local mutable copies for cargs / cparams in do_connect

Fixed a critical issue in :class:`.Engine` where connections created in
conjunction with the :meth:`.ConnectionEvents.do_connect` event listeners
would receive shared, mutable collections for the connection arguments,
leading to a variety of potential issues including unlimited growth of the
argument list as well as elements within the parameter dictionary being
shared among concurrent connection calls.  In particular this could impact
do_connect routines making use of complex mutable authentication
structures.

Fixes: #13144
Change-Id: I1549dae36e8e7e6cf50fdaf796659b53e7b78234
(cherry picked from commit dfb1c49cd7306eeca49fd7bb7ec4bcbef0e68d79)

3 months agoVersion 2.0.48 placeholder
Mike Bayer [Tue, 24 Feb 2026 16:38:55 +0000 (11:38 -0500)] 
Version 2.0.48 placeholder

3 months ago- 2.0.47 rel_2_0_47
Mike Bayer [Tue, 24 Feb 2026 16:21:39 +0000 (11:21 -0500)] 
- 2.0.47

3 months agofix an idiosyncratic F821 failure
Mike Bayer [Tue, 24 Feb 2026 16:03:24 +0000 (11:03 -0500)] 
fix an idiosyncratic F821 failure

this fail only occurs:

1. with python 3.13 (maybe earlier also?)
2. in the 2.0 branch.   identical code is in main and does not fail
(identical flake8 settings too)

can't narrow down why this one occurs but it's failing
GH actions so just patch it

Change-Id: Ib1655856e0363b9dc365e093a86eecc75e5d783c

3 months agoFix WeakSequence.__getitem__ catching KeyError instead of IndexError
Kadir Can Ozden [Sat, 21 Feb 2026 11:35:38 +0000 (06:35 -0500)] 
Fix WeakSequence.__getitem__ catching KeyError instead of IndexError

### Description

`WeakSequence.__getitem__` catches `KeyError` but the internal `_storage` is a `list`, which raises `IndexError` for out-of-range access. This means the `except KeyError` handler never executes, and the custom error message is never shown.

### Current behavior

```python
def __getitem__(self, index):
    try:
        obj = self._storage[index]  # _storage is a list
    except KeyError:  # lists don't raise KeyError
        raise IndexError("Index %s out of range" % index)
    else:
        return obj()
```

On an out-of-range index, the raw `IndexError` from list access propagates directly (e.g., `list index out of range`) instead of the intended custom message.

### Fix

Changed `except KeyError` to `except IndexError` so the handler actually catches the exception raised by list indexing.

Closes: #13136
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13136
Pull-request-sha: ceb8f9fe46590ec69686769f6736686789c88986

Change-Id: Ia36c2b9b0f3aec97624bcd2a9e49f43b9ed786d9
(cherry picked from commit 0f74af5c339d7f3a6412537571aa60c0180be426)

3 months agoMysql ddl compiler fall back to default index args
Tiansu Yu [Fri, 20 Feb 2026 14:20:40 +0000 (09:20 -0500)] 
Mysql ddl compiler fall back to default index args

Fixed issue where DDL compilation options were registered to the hard-coded
dialect name ``mysql``. This made it awkward for MySQL-derived dialects
like MariaDB, StarRocks, etc. to work with such options when different sets
of options exist for different platforms. Options are now registered under
the actual dialect name, and a fallback was added to help avoid errors when
an option does not exist for that dialect. Pull request courtesy Tiansu Yu.

Fixes: #13134
Closes: #13138
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13138
Pull-request-sha: 1bc953a2a1be97f82cdbbbc0d8961361716190fa

Change-Id: Ifa700a4e34da4d1923e9473dd8f0d2417dcfded4
(cherry picked from commit 8c262051247d5d83f3d0269003705a363dbc3e60)

3 months agodowngrade batches for bindparam() in SET
Mike Bayer [Tue, 17 Feb 2026 20:58:22 +0000 (15:58 -0500)] 
downgrade batches for bindparam() in SET

Fixed issue where :meth:`_postgresql.Insert.on_conflict_do_update`
using parametrized bound parameters in the ``set_`` clause would fail
when used with executemany batching. For dialects that use the
``use_insertmanyvalues_wo_returning`` optimization (psycopg2),
insertmanyvalues is now disabled when there is an ON CONFLICT clause.
For cases with RETURNING, row-at-a-time mode is used when the SET
clause contains parametrized bindparams (bindparams that receive
values from the parameters dict), ensuring each row's parameters are
correctly applied. ON CONFLICT statements using expressions like
``excluded.<column>`` continue to batch normally.

Fixed issue where :meth:`_sqlite.Insert.on_conflict_do_update`
using parametrized bound parameters in the ``set_`` clause would fail
when used with executemany batching. Row-at-a-time mode is now used
for ON CONFLICT statements with RETURNING that contain parametrized
bindparams, ensuring each row's parameters are correctly applied. ON
CONFLICT statements using expressions like ``excluded.<column>``
continue to batch normally.

Fixes: #13130
Change-Id: I0c5a9142401c745d38e58d071c16e53610f9bfea
(cherry picked from commit 5b2e7aae01cc2e55e68a8445569ee709b17715dd)

3 months agoPoolProxiedConnection support context protocol
Federico Caselli [Mon, 9 Feb 2026 21:47:19 +0000 (22:47 +0100)] 
PoolProxiedConnection support context protocol

The connection object returned by :meth:`_engine.Engine.raw_connection`
now supports the context manager protocol, automatically returning the
connection to the pool when exiting the context.

Fixes: #13116
Change-Id: I51eb1fd61b772368f12a787e5f60db153a839e70
(cherry picked from commit 6fa097ed100dbe5553796c3b45efc50f614c2371)

3 months agodocument thread starvation as a cause of pool exhaustion
Mike Bayer [Mon, 9 Feb 2026 14:26:38 +0000 (09:26 -0500)] 
document thread starvation as a cause of pool exhaustion

Fixes: #7679
Change-Id: I5f2619ac73a5e1f34b9131fe549122998db8a29a
(cherry picked from commit cf0cc646d6700b25a0c7314ec1f9fe75ef1692ab)

3 months agoPostgreSQL / SQLite / Insert.on_conflict_do_update: respect compile_kwargs
Loïc Simon [Thu, 5 Feb 2026 19:56:26 +0000 (14:56 -0500)] 
PostgreSQL / SQLite / Insert.on_conflict_do_update: respect compile_kwargs

Fixed issue where :meth:`_postgresql.Insert.on_conflict_do_update`
as well as  :meth:`_sqlite.Insert.on_conflict_do_update`
parameters were not respecting compilation options such as
``literal_binds=True``.

Pull request courtesy Loïc Simon.

Fixes: #13110
Closes: #13111
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13111
Pull-request-sha: 9ca251610b2eb1c5fdda6aeffa6e81dcaef23aaa

Change-Id: Ice21e508210d682098104c78e77bad8d24e6c93f
(cherry picked from commit 6b09777e3d1ef35eb0ed07843b51d1a525702b79)

3 months agoallow batch with upsert if embed_values_counter is True
Mike Bayer [Wed, 4 Feb 2026 02:07:59 +0000 (21:07 -0500)] 
allow batch with upsert if embed_values_counter is True

Fixed issue in the :ref:`engine_insertmanyvalues` feature where using
PostgreSQL's ``ON CONFLICT`` clause with
:paramref:`_dml.Insert.returning.sort_by_parameter_order` enabled would
generate invalid SQL when the insert used an implicit sentinel (server-side
autoincrement primary key). The generated SQL would incorrectly declare a
sentinel counter column in the ``imp_sen`` table alias without providing
corresponding values in the ``VALUES`` clause, leading to a
``ProgrammingError`` indicating column count mismatch. The fix allows batch
execution mode when ``embed_values_counter`` is active, as the embedded
counter provides the ordering capability needed even with upsert behaviors,
rather than unnecessarily downgrading to row-at-a-time execution.

Fixes: #13107
Change-Id: I382472b2cf2991b520344adea5783584e27425d0
(cherry picked from commit 574facaaf4207b952379c28673c44b62835535fb)

4 months agoparse ON UPDATE / ON DELETE in any order
Mike Bayer [Tue, 3 Feb 2026 21:11:13 +0000 (16:11 -0500)] 
parse ON UPDATE / ON DELETE in any order

Fixed an issue in the PostgreSQL dialect where foreign key constraint
reflection would incorrectly swap or fail to capture ``onupdate`` and
``ondelete`` values when these clauses appeared in a different order than
expected in the constraint definition. This issue primarily affected
PostgreSQL-compatible databases such as CockroachDB, which may return ``ON
DELETE`` before ``ON UPDATE`` in the constraint definition string. The
reflection logic now correctly parses both clauses regardless of their
ordering.

Fixes: #13105
Change-Id: I1331b433f713632e84ae6a34467806e080b8003e
(cherry picked from commit 6fbdd3602136fe7589238c657f61de60b85c3c54)

4 months agoforwards-port cpython issue 141560 for getfullargspec
Mike Bayer [Tue, 3 Feb 2026 13:53:53 +0000 (08:53 -0500)] 
forwards-port cpython issue 141560 for getfullargspec

Fixed issue when using ORM mappings with Python 3.14's :pep:`649` feature
that no longer requires "future annotations", where the ORM's introspection
of the ``__init__`` method of mapped classes would fail if non-present
identifiers in annotations were present.  The vendored ``getfullargspec()``
method has been amended to use ``Format.FORWARDREF`` under Python 3.14 to
prevent resolution of names that aren't present.

Fixes: #13104
References: https://github.com/python/cpython/issues/141560
Change-Id: I6af8026a07131d4a1e28cd7fc2e90509194ae957
(cherry picked from commit be37eb8d3061a316d82051d1a7eb670fc65b5fb0)

4 months agoallow 2 uncleared connections at most
Mike Bayer [Fri, 30 Jan 2026 15:32:52 +0000 (10:32 -0500)] 
allow 2 uncleared connections at most

tests show that if the code is really broken, we have
5 or more connections lingering here, so for less than two
(it's usually one) just clean it out and consider it as GC noise.

To test this better we also open up the windows/mac archs that
were disabled for greenlet

Fixes: #13102
Change-Id: Iccf419e7f345bcae4a388d222ab69fc792a3c1ca
(cherry picked from commit ff2c7668fe90b43b75dcb0d6e7651349dd715e5a)

4 months agoAdd external dialects for DynamoDB and MongoDB (#13100)
Peng Ren [Thu, 29 Jan 2026 19:52:43 +0000 (14:52 -0500)] 
Add external dialects for DynamoDB and MongoDB (#13100)

(cherry picked from commit 290378a57a65e0db2862a6fb7f1de8b5d22bac31)

4 months 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
(cherry picked from commit 325addda8b569581f5c5537cbbb76ef70da6534d)

4 months 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)

(cherry picked from commit 53e2966dc0dab99f5814b5a84f4ab7435a4e216e)

4 months agoVersion 2.0.47 placeholder
Mike Bayer [Wed, 21 Jan 2026 18:04:03 +0000 (13:04 -0500)] 
Version 2.0.47 placeholder

4 months ago- 2.0.46 rel_2_0_46
Mike Bayer [Wed, 21 Jan 2026 17:59:27 +0000 (12:59 -0500)] 
- 2.0.46

4 months 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
(cherry picked from commit d0d9f1b71115471b0a6918075383c2bddf2212b1)

4 months agodocs: fix grammar in reflection documentation
Imad Saddik [Tue, 20 Jan 2026 20:52:24 +0000 (21:52 +0100)] 
docs: fix grammar in reflection documentation

(cherry picked from commit d1026e788cad26ee507bb79fa7b8b316c81166e2)

4 months 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
(cherry picked from commit c36643fbb933c0defd00b9caa7a184c24e2a544b)

4 months 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
(cherry picked from commit 63885906e8a5f6ad479e591e4f5716b486ef1df6)

4 months agohappy new year
Mike Bayer [Wed, 14 Jan 2026 18:01:21 +0000 (13:01 -0500)] 
happy new year

Change-Id: I86954844fe5ae036758c332b9a033851d3266ca9

4 months 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
(cherry picked from commit 48410f83407661e009326d7170ab79e5163eb8f1)