]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
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 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)

2 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)

2 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)

3 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)

3 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)

4 months agoremove paragraph re: init=False as I think this is a 2.1 thing
Mike Bayer [Fri, 9 Jan 2026 14:19:22 +0000 (09:19 -0500)] 
remove paragraph re: init=False as I think this is a 2.1 thing

Change-Id: I78a61f75a2288e6823704cd10fcbbdb52352a25d

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

References: #13068
Change-Id: Ie08ad4120a21bf24c8e5704340c525299b9894fd
(cherry picked from commit 47266b11b7b4ef81c34c199f9b75424dfebbee60)

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

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

5 months 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
(cherry picked from commit 380c234ce901416ca3c04453744f33d53cc4bd55)

5 months 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
(cherry picked from commit a88f89849e303ab441082de788545ee8a698dc2e)

5 months 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
(cherry picked from commit 0a1be6dcfab7b17613835248a368e6b822a53319)

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

5 months 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>
(cherry picked from commit 81e72ca9cd4230bd29cebc3965cc6fa0913e26e3)

Change-Id: I016b3ce4a981a09a60bb302cc38badff8b1fe24d

5 months 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
(cherry picked from commit 40fc3c90e1fee3f7a19184ab57cca3cbcdfa6da1)

5 months 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>
(cherry picked from commit fb408b8e9d2e4ca7ac446c3d8dbd42c66b69b5a3)

Change-Id: I29c3229aa475b51b6a7055dd5d149283ef1a08a8

5 months 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
(cherry picked from commit b4068fd0227b980bb9e6340befd649d4d261c2c7)

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

(cherry picked from commit 7194b5ba3de050815ea20aafb80d262b6fcd1d07)

Change-Id: Ib462035322aaeacd733386f5db6883a811b36a4d

5 months 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
(cherry picked from commit 01dcb7a967fd91b0764e83dabaed0a8a7bfa78ec)

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

5 months agocleaup test pipeline
Federico Caselli [Wed, 10 Dec 2025 20:06:44 +0000 (21:06 +0100)] 
cleaup test pipeline

Change-Id: Ic29289686139f27df3c3802f20ca4cbd2105778c

5 months agoFix wheel pipeline
Federico Caselli [Wed, 10 Dec 2025 20:02:34 +0000 (21:02 +0100)] 
Fix wheel pipeline

Change-Id: I97b47160b619a454e421a94396a2fb8116dada6e

5 months 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
(cherry picked from commit 9cd9b6b5896333f779f484c73f3c1119448305b5)

5 months agoMerge "additional check for dc test" into rel_2_0
Michael Bayer [Wed, 10 Dec 2025 14:34:53 +0000 (14:34 +0000)] 
Merge "additional check for dc test" into rel_2_0

5 months 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
(cherry picked from commit 668ea5b7384297236330ead78919889b4473807f)

5 months 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
(cherry picked from commit 292aa19698326793003c0ebb2c75f6863d039573)

5 months 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
(cherry picked from commit 3cad9e372b98b96e9493ad383b2e44301b4b58f4)

5 months agoVersion 2.0.46 placeholder
Mike Bayer [Tue, 9 Dec 2025 21:06:37 +0000 (16:06 -0500)] 
Version 2.0.46 placeholder

5 months ago- 2.0.45 rel_2_0_45
Mike Bayer [Tue, 9 Dec 2025 20:54:35 +0000 (15:54 -0500)] 
- 2.0.45

5 months agoMerge "Factor out constraints into separate methods" into rel_2_0
Michael Bayer [Tue, 9 Dec 2025 20:45:35 +0000 (20:45 +0000)] 
Merge "Factor out constraints into separate methods" into rel_2_0

5 months 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
(cherry picked from commit 9fe3c3cd30bd7d4afc877bb2243ba7679ebe185d)

5 months 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
(cherry picked from commit e4a802f99a0bca813dd29e8dc88bb5e5aaddff93)

5 months 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
(cherry picked from commit f58ea194d5190859baef66c183fa0228f629830c)

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

Change-Id: I5a440f9d3a8bb5afb45b0af4d9f1a112255d5f96
(cherry picked from commit c7bd25650adf6babc8f39eb61b42eb626d92261f)

5 months agouse plain 3.14 for test runs
Mike Bayer [Mon, 8 Dec 2025 14:14:26 +0000 (09:14 -0500)] 
use plain 3.14 for test runs

this was already applied to main previously

Change-Id: Id0d6a16e3be645ecf30cdbd238b4a9867791fd79

5 months 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
(cherry picked from commit 66d55b51992a463beef47212992e5b2914f9e586)

5 months 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
(cherry picked from commit 133f14dabed44f7398039e2556bf9b7107f3922e)

5 months agoMerge "run sentinel server side fns outside of VALUES" into rel_2_0
Michael Bayer [Wed, 3 Dec 2025 16:56:18 +0000 (16:56 +0000)] 
Merge "run sentinel server side fns outside of VALUES" into rel_2_0

6 months 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
(cherry picked from commit c5d09f5ed4b4e37cfdd033026e2f67382ee9fcb3)

6 months 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
(cherry picked from commit 40c2400af7d44a528358ea1d73c275a85bb75616)

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

6 months agoadd python 3.14 wheels + free threaded
Mike Bayer [Mon, 1 Dec 2025 20:22:54 +0000 (15:22 -0500)] 
add python 3.14 wheels + free threaded

the freethreadeds are in a separate task so if they fail,
we still have wheels published

Change-Id: Ie28483cc379cf3db01afe2a2b4c475a9fbfbb9e5

6 months agoadditional fixes re: mariadb innodb etc.
Mike Bayer [Sat, 29 Nov 2025 03:47:40 +0000 (22:47 -0500)] 
additional fixes re: mariadb innodb etc.

fix a bunch of side effects that were not tested in the gerrit
phase because we run with --backendonly

Change-Id: Iebcedb962e6e11dd247b0da5f309a71db711694c
(cherry picked from commit 2169a2950479873cd42d62c3f81a6bd7caa8aaeb)

6 months agodrop a 400 ton anvil on oracle 23c
Mike Bayer [Thu, 27 Nov 2025 06:22:38 +0000 (01:22 -0500)] 
drop a 400 ton anvil on oracle 23c

this DB is extremely erratic in being able to connect.   Add
a brute force connection retrier to all engines everywhere
(which for oracledb we can fortunately use their built-in feature
that also works).
This actually works and I can see it pausing under load, reconnecting,
and succeeding.  the problem is that absolutely every engine everywhere
needs this routine otherwise an engine without a retrier in it will
crash.    That then necessitates digging into testing_engine(),
making sure testing_engine() is used everywhere an engine that's going
to connect is used, then dealing with the fallout from that.

We also simplify some older workarounds for cx_oracle and
hack into config/provision to make oracledb seem like the primary
DBAPI for most tests.

testing_engine has been completely overhauled, making use of a new
post_configure_testing_engine() hook which moves and refines
the SQLite pool sharing and savepoint logic all into sqlite/provision.py
and also allows for cx_oracle to apply a retry event handler.

Change-Id: I4ea4c523effb878290d28b94d8925eb32fc5ae3b
(cherry picked from commit af768d0c3c33fc2dfc6dfc7ce847dd88bd31bc06)

6 months agohappy mypy day; backport the bump to pytest 9
Mike Bayer [Fri, 28 Nov 2025 16:55:36 +0000 (11:55 -0500)] 
happy mypy day; backport the bump to pytest 9

Change-Id: I5beb5770e916b41438720c2d4e474eef1ba6598c

6 months agostop using MyISAM; more oracle struggles
Mike Bayer [Wed, 26 Nov 2025 06:36:57 +0000 (01:36 -0500)] 
stop using MyISAM; more oracle struggles

getting some fails on mariadb12 and likely 11 which appear to
be related to calling in MyISAM, which is not used in
modern mysql/mariadb.   see if we can just remove this whole
thing and rely on default engines for mariadb/mysql.

this change also removes the "ignore errors" part of the
run deletes for the TablesTest fixture, which was resulting
in compound failures, and apparently a lot of tests were relying
on it skipping nonexistent tables.   rather than check for that
we should just improve the tests and probably increase use of
pytest style fixtures overall.

this change also identifies and fixes that memusage_w_backend
tests were running for all backends with a tag like
py314_mysql_backendonly; the memusage tests should basically
never be run as part of the whole suite since they are entirely
unreliable within a full scale test run.

dialect suite tests are also further broken out into those where
every driver should be exercised (i.e. __backend__, for tests that
test datatypes going out and coming back from the database as well
as identity/autoincrement kinds of tests) vs. those where only
one driver per backend is needed (i.e. __sparse_driver_backend__,
for tests like reflection, DDL, CTEs, etc.).

we are also trying to get a --low-connections option that actually
works.  changed this so that the testing reaper aggressively disposes
the "global" engines (one per backend / driver) after test classes
are done and before any testing_engine() call.   This definitely
works, however some monitoring with PG shows the number of connections
still has brief bursts for some reason.   it should be much more
effective than before though as oracle 23/26 really does not handle
more than a few connections.

this change reverts oracle to oracle18c for now in setup.cfg;
further work will be needed to determine if oracle23c can be
run with this test suite

Change-Id: Id87d0ea15155c452615a7edeb9d434c8e55151e7
(cherry picked from commit 88028954576a8d7e772160d74b14da62c0b4fd43)

6 months agore-enable vectore test in oracle
Federico Caselli [Tue, 25 Nov 2025 21:48:01 +0000 (22:48 +0100)] 
re-enable vectore test in oracle

Change-Id: I382a20027f36f32617d2680332873f1b7d5bcee6
(cherry picked from commit 09ce4d07540628dfac84bf500e9bbddbca48dc9f)

6 months agotest oracle 23c, mariadb12; reduce backend use
Mike Bayer [Tue, 25 Nov 2025 00:33:18 +0000 (19:33 -0500)] 
test oracle 23c, mariadb12; reduce backend use

one particular vector test wont run on oracle 23c free, so
just disable it.

added better skips for the rest of the vector tests and
fixed a deprecation issue.

this will be the first run on the new oracle23 on CI so we'll have to
see how this goes.

Also adjust for mariabdb12 being overly helpful with regards
to stale row updates.

as we are having trouble getting 23c to pass throug transaction
tests, i noted we have an explosion of tests due to the multiple
drivers, so this patch introduces __sparse_driver_backend__
for all tests where we want variety of
database server but there's no need to test every driver.
This should dramatically reduce the size of the test suite run

Change-Id: Ic8d3eb0a60e76b4c54c6bb4a721f90c81ede782b
(cherry picked from commit 8ce47663c238b230400d3603fa403eb5fed227dc)

6 months agobreak up test_update_delete_where into several files
Mike Bayer [Fri, 21 Nov 2025 18:44:31 +0000 (13:44 -0500)] 
break up test_update_delete_where into several files

it's grown to 3K lines and i need to add more tests

Change-Id: Ic55c50446d57789e3e3cc58e6a99239c1bfa8328
(cherry picked from commit 871e66e058fafae8f54d68359370c022d51059e1)

6 months agouse zimports 0.7.0
Mike Bayer [Thu, 20 Nov 2025 18:44:09 +0000 (13:44 -0500)] 
use zimports 0.7.0

this adds pyproject.toml support

Change-Id: I6d00fc912f25405542326c3d0ffcfb1969cea24b
(cherry picked from commit 708a0360b17b6cae0135f1d6143b0ee1e88e885c)

6 months agoFix type hint for with_for_update() to support tuples of table classes
Shamil [Wed, 19 Nov 2025 13:02:28 +0000 (08:02 -0500)] 
Fix type hint for with_for_update() to support tuples of table classes

Fixed typing issue where :meth:`.Select.with_for_update` would not support
lists of ORM entities in the :paramref:`.Select.with_for_update.of`
parameter. Pull request courtesy Shamil.

Fixes: #12730
Closes: #12988
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12988
Pull-request-sha: 41a38bfe38d8b66da853012e7165cc0cacf7f28a

Change-Id: I61d60a4f4d2b16037da8d5f30e33f5d74fa47374
(cherry picked from commit a057c474bf84ccd0508b89aa5428f45c9a644ee3)

6 months agopropagate _scalar_type() for SelectStatementGrouping
Mike Bayer [Tue, 18 Nov 2025 20:10:05 +0000 (15:10 -0500)] 
propagate _scalar_type() for SelectStatementGrouping

Fixed issue where using the :meth:`.ColumnOperators.in_` operator with a
nested :class:`.CompoundSelect` statement (e.g. an ``INTERSECT`` of
``UNION`` queries) would raise a :class:`NotImplementedError` when the
nested compound select was the first argument to the outer compound select.
The ``_scalar_type()`` internal method now properly handles nested compound
selects.

Fixes: #12987
Change-Id: I6aa1b38863588d371bbac74b3531b99ccd5fcaec
(cherry picked from commit 42710c9220f897487710424981b81a69a7da5def)

6 months agoupdate lint setup
Mike Bayer [Mon, 17 Nov 2025 21:32:54 +0000 (16:32 -0500)] 
update lint setup

We are stuck on flake8 because we rely on many plugins with
specific behaviors.  The situation has calcified where:

1. the whole world uses ruff
2. nobody cares about import order linting or all the other stuff
   we do, and/or similar but not quite the same things are embedded
   deeply into ruff which would require us giving up a lot of our
   standards (like isort)
3. flake8 is absolutely never going to support pyproject.
4. flake8-pyproject works for this

beyond that, for t string support we want to make it easy
to get onto py3.14, so here we update black to the latest which
appears to fix some missing symbols for py3.14 t strings.

we should also migrate the remaining sqlalchemy test config
from setup.cfg to pyproject.toml but that should likely be
2.1 only

Change-Id: I896a7c839148d0ef516728c73baddc8eddf5ee96
(cherry picked from commit f6714c8e090b9dd84ac4256ed74eefc1fe9cbddc)

6 months agoadd highlight for python3 over api doc sections
Mike Bayer [Sun, 16 Nov 2025 15:55:54 +0000 (10:55 -0500)] 
add highlight for python3 over api doc sections

the pycon+sql highlight seems to take effect for docstrings
now in sphinx 8 or whatever.

Fixes: #12981
Change-Id: Ifab2c66d6adddf3ce5336f244653a336ac0d2ce9
(cherry picked from commit 5af013026fe995bb7abd95005913026ea13d020c)

6 months agobump nox to latest main + fix
Mike Bayer [Sat, 15 Nov 2025 16:41:34 +0000 (11:41 -0500)] 
bump nox to latest main + fix

apparently 2.0 was behind so this copies
the files with 2.0-specific modifications from the below change id

add pyv to file template; use = for all custom args

adding "test/" to pytest doesnt work because then we can't indicate
a specific set of test files.  use = for all sqlalchemy-custom
parameters instead to avoid [1]

[1] https://github.com/pytest-dev/pytest/issues/13913

Change-Id: I9eb5bbfac734fcb145fcf3ae58fcc55df6bb6e71

6 months agoAdd Mimer SQL to list of external dialects (#12969)
Fredrik Ålund [Wed, 12 Nov 2025 23:05:21 +0000 (00:05 +0100)] 
Add Mimer SQL to list of external dialects (#12969)

(cherry picked from commit d96c04950d6a1a72961a097289f7fd850319e3d0)

6 months agoTyping: fix type of func.coalesce when used with hybrid properties
Yannick PÉROUX [Tue, 4 Nov 2025 17:58:03 +0000 (12:58 -0500)] 
Typing: fix type of func.coalesce when used with hybrid properties

Fixed typing issue where :class:`.coalesce` would not return the correct
return type when a nullable form of that argument were passed, even though
this function is meant to select the non-null entry among possibly null
arguments.  Pull request courtesy Yannick PÉROUX.

Closes: #12963
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12963
Pull-request-sha: 05d0d9784d4497fb3bfee540fbc51747c1767c90

Change-Id: Ife83a384ea57faf446c1fdb542df14627348f40f
(cherry picked from commit d160cb5314239ef9487c84aa5173e946d57804fd)

6 months agofeat: Support MySQL FOR SHARE locking syntax.
JetDrag [Wed, 5 Nov 2025 03:47:02 +0000 (22:47 -0500)] 
feat: Support MySQL FOR SHARE locking syntax.

Added support for MySQL 8.0.1 + ``FOR SHARE`` to be emitted for the
:meth:`.Select.with_for_uddate` method, which offers compatibility with
``NOWAIT`` and ``SKIP LOCKED``.  The new syntax is used only for MySQL when
version 8.0.1 or higher is detected. Pull request courtesy JetDrag.

Fixes: #10134
Closes: #12964
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12964
Pull-request-sha: 03d5e37cfda5da9dab8ae00aa682521f8ab9190b

Change-Id: Iafb7a24363284edcfeead94a348f50a470a88403
(cherry picked from commit 59afd08a5206c69ce47c138c6e4f18b2c40e1ef6)

6 months agodont fail if imports not set up
Mike Bayer [Mon, 10 Nov 2025 13:43:10 +0000 (08:43 -0500)] 
dont fail if imports not set up

this is to help with vscode extensions

Change-Id: I4dc6c07bec8158c82e376b3399d6e0e104360bf2
(cherry picked from commit 828bedbe3ab096d30ade65e387feaffe6c1207e5)

6 months agoadd missing changelog for #12954
Mike Bayer [Tue, 4 Nov 2025 21:56:34 +0000 (16:56 -0500)] 
add missing changelog for #12954

Change-Id: I9b779230c236884dc58f79c97e65bd6c983b252e
(cherry picked from commit 1bddbd9e58a2835dbc3539ffc38a93a4cb85a105)

6 months agodouble guard import issue
Mike Bayer [Tue, 4 Nov 2025 14:56:39 +0000 (09:56 -0500)] 
double guard import issue

3.13 has an import issue, 3.14 has a "hey why are you ignoring here"
issue, solve them both

this then cascaded into zimport uncooperativeness so had to
fix that and put out 0.6.3, so this becomes more of a thing

Change-Id: I5c01e48af2af14be17c3e5f2a53e7913444b98eb
(cherry picked from commit f4c08c07d0ea4d18d384925f4c7d46f05566f42b)

6 months agoclarify Core / ORM insert parameter behaviors
Mike Bayer [Tue, 4 Nov 2025 14:13:45 +0000 (09:13 -0500)] 
clarify Core / ORM insert parameter behaviors

it seems to have gotten lost in our newer docs that we're looking
at the first dict only for core insert.  add sections to both
INSERT tutorials explaining this difference

references: #12962
Change-Id: Id2e6c7e7db57fba6aa7838d5c3c65dea1939445a
(cherry picked from commit 7beb71d208955f8badef270c67eb47f3caac1f96)

6 months agoAdd order by clause to dialect tests to ensure expected result order
Pat Buxton [Mon, 3 Nov 2025 14:49:33 +0000 (09:49 -0500)] 
Add order by clause to dialect tests to ensure expected result order

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

### Description
Failing for Starrocks dialect currently without overrides, the amended dialect tests require an order by clause to ensure the expected result.

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

Fixes https://github.com/sqlalchemy/sqlalchemy/issues/12956

Closes: #12957
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12957
Pull-request-sha: 271a014896e0c3d994112dec19029261d4507b6d

Change-Id: Ib8f5bc1caf014026071b83f57011c43c02043746
(cherry picked from commit a87faba35a65563447c8204cc47eb37ab47e216e)

7 months agouse the default driver for sparse backend
Mike Bayer [Sat, 1 Nov 2025 13:56:18 +0000 (09:56 -0400)] 
use the default driver for sparse backend

the memusage tests use sparse_backend but should use the
main driver in a set; they were using the pysqlite_numeric
dialect which is not a real dialect and apparently runs
dramatically slower for the memusage tests since it generates
more memory artifacts.

Change-Id: Icf19ac1a3cae862a48ddcec565079c960b8ac2b7
(cherry picked from commit 725d1a19b4e638c4a5ef40534397423c6c016614)

7 months agofix sqlite regex for quoted fk, pk names
Mike Bayer [Sat, 1 Nov 2025 02:57:28 +0000 (22:57 -0400)] 
fix sqlite regex for quoted fk, pk names

Fixed issue where SQLite dialect would fail to reflect constraint names
that contained uppercase letters or other characters requiring quoting. The
regular expressions used to parse primary key, foreign key, and unique
constraint names from the ``CREATE TABLE`` statement have been updated to
properly handle both quoted and unquoted constraint names.

Fixes: #12954
Change-Id: If5c24f536795e5db867d857242013610a04638fc
(cherry picked from commit cdaf1824316ba6fa7b52164b50cd9fd4aeb2c41f)

7 months agoensure util.get_annotations() is used
Mike Bayer [Fri, 31 Oct 2025 15:51:37 +0000 (11:51 -0400)] 
ensure util.get_annotations() is used

Fixed issue in Python 3.14 where dataclass transformation would fail when
a mapped class using :class:`.MappedAsDataclass` included a
:func:`.relationship` referencing a class that was not available at
runtime (e.g., within a ``TYPE_CHECKING`` block). This occurred when using
Python 3.14's :pep:`649` deferred annotations feature, which is the
default behavior without a ``from __future__ import annotations``
directive.

Fixes: #12952
Change-Id: I32f0adba00c32f5bf98fe2880dda1b96a7774d07
(cherry picked from commit 03dbd830e174685964191f739ea784f51c97d6b3)

7 months agoMerge "Add docs for using Psycopg 3 connection pooling" into rel_2_0
Michael Bayer [Wed, 29 Oct 2025 15:38:55 +0000 (15:38 +0000)] 
Merge "Add docs for using Psycopg 3 connection pooling" into rel_2_0

7 months agofix session cursor result tip
Mike Bayer [Wed, 29 Oct 2025 12:08:03 +0000 (08:08 -0400)] 
fix session cursor result tip

in 2.0, we are usually not returning CursorResult for
Session.execute().

References: #12813
Change-Id: I19049b57790b5429ce7890c86e87b93c07a3f1d2
(cherry picked from commit e2bda66b5115cc628ebce9423877586c9e817feb)

7 months agomissed yet another force dereference
Mike Bayer [Tue, 28 Oct 2025 23:41:10 +0000 (19:41 -0400)] 
missed yet another force dereference

Change-Id: I75204886b7a48a6148e47e18d28a0465f908c09d
(cherry picked from commit b8c5fd8588aeaea8077560b68c0ce85bfd2dfc3f)