Commit Graph

17419 Commits

Author SHA1 Message Date
Mike Bayer a303102a7b - 2.0.43 rel_2_0_43 2025-08-11 10:20:06 -04:00
Mike Bayer 385b267a2e maintain alphabetical create_engine() param ordering
the name changed on this so it needs to be moved down

Change-Id: I119c3f5db9262c80b6dd2175e1e56073776607cf
(cherry picked from commit bcd6bba54b)
2025-08-11 10:19:43 -04:00
Mike Bayer d6be70e35b doc fixes
Change-Id: Iee65f09ea17bfa7a39fe3da05f22007f92b76f29
(cherry picked from commit b5172fcdb7)
2025-08-11 10:15:50 -04:00
suraj 8ed3922805 Fixes: #12711 Added sparse vector support in Oracle
Extended :class:`_oracle.VECTOR` to support sparse vectors. This update
introduces :class:_oracle.VectorStorageType to specify sparse or dense
storage and added :class:`_oracle.SparseVector`. Pull request courtesy
Suraj Shaw.

Fixes: #12711
Closes: #12712
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12712
Pull-request-sha: 5a4199de1e

Change-Id: Icdda9520a5f752e923f087edb166b4032f5bfd21
(cherry picked from commit d8e6654427)
2025-08-11 08:34:53 -04:00
Mike Bayer 908e29671f ensure autocommit is not False for SQLite FK pragma
References: #12767
References: https://github.com/python/cpython/issues/137205
Change-Id: I6772a4c9c216c6981421043f850cbf833ded2be3
(cherry picked from commit e96bf8608e)
2025-08-07 10:51:57 -04:00
Michael Bayer 6ca97fee95 Merge "implement skip_autocommit_rollback" into rel_2_0 2025-08-07 14:46:11 +00:00
Mike Bayer eea260f5be implement skip_autocommit_rollback
Added new parameter :paramref:`.create_engine.skip_autocommit_rollback`
which provides for a per-dialect feature of preventing the DBAPI
``.rollback()`` from being called under any circumstances, if the
connection is detected as being in "autocommit" mode.   This improves upon
a critical performance issue identified in MySQL dialects where the network
overhead of the ``.rollback()`` call remains prohibitive even if autocommit
mode is set.

Fixes: #12784
Change-Id: I22b45ab2fc396c5aadeff5cdc5ce895144d00098
(cherry picked from commit 99da878a25)
2025-08-06 14:38:12 -04:00
Mike Bayer 435b22e41d add chunking to selectin_polymorphic
Improved the implementation of the :func:`_orm.selectin_polymorphic`
inheritance loader strategy to properly render the IN expressions using
chunks of 500 records each, in the same manner as that of the
:func:`_orm.selectinload` relationship loader strategy.  Previously, the IN
expression would be arbitrarily large, leading to failures on databases
that have limits on the size of IN expressions including Oracle Database.

Fixes: #12790
Change-Id: I8df7f34d4fdf73996780772d983b72ea0fc8309e
(cherry picked from commit 9d6fa58d69)
2025-08-06 14:00:38 -04:00
Michael Bayer 3ba16238f9 Merge "Fix use_existing_column with Annotated mapped_column in polymorphic inheritance" into rel_2_0 2025-08-06 14:39:36 +00:00
Mike Bayer 0de4eb17be apply correct pre-fetch params to post updated rows
Fixed issue where using the ``post_update`` feature would apply incorrect
"pre-fetched" values to the ORM objects after a multi-row UPDATE process
completed.  These "pre-fetched" values would come from any column that had
an :paramref:`.Column.onupdate` callable or a version id generator used by
:paramref:`.orm.Mapper.version_id_generator`; for a version id generator
that delivered random identifiers like timestamps or UUIDs, this incorrect
data would lead to a DELETE statement against those same rows to fail in
the next step.

Fixes: #12748
Change-Id: Id12c7973f168604533762dfc01afbb9155b693a6
(cherry picked from commit f4d9c10755)
2025-08-05 17:12:55 -04:00
Mike Bayer ebd7c715fb Fix use_existing_column with Annotated mapped_column in polymorphic inheritance
Fixed issue where :paramref:`_orm.mapped_column.use_existing_column`
parameter in :func:`_orm.mapped_column` would not work when the
:func:`_orm.mapped_column` is used inside of an ``Annotated`` type alias in
polymorphic inheritance scenarios. The parameter is now properly recognized
and processed during declarative mapping configuration.

Fixes: #12787
Change-Id: I0505df3f3714434e98052c4488f6b1b1d2b1f755
(cherry picked from commit 14a18d4591)
2025-08-05 14:59:36 -04:00
Mike Bayer b5f494e8b9 Fix PostgreSQL JSONB subscripting regression with functions
Fixed regression in PostgreSQL dialect where JSONB subscription syntax
would generate incorrect SQL for JSONB-returning functions, causing syntax
errors. The dialect now properly wraps function calls and expressions in
parentheses when using the ``[]`` subscription syntax, generating
``(function_call)[index]`` instead of ``function_call[index]`` to comply
with PostgreSQL syntax requirements.

Fixes: #12778
Change-Id: If1238457e6bba6a933023b26519a41aa5de4dbcd
(cherry picked from commit d37d56c1ad)
2025-08-04 15:06:54 -04:00
Federico Caselli aea30bcd13 update install faq to align with code
Change-Id: Id032859c02803cd561bff00b4eb773eff933abbc
References: #12757
2025-07-30 22:41:21 +02:00
Sviatoslav Bobryshev 46c9cc3ffe Remove unnecessary r-prefix from docstring in 'columns' method (#12768)
(cherry picked from commit 52e80cd05d)
2025-07-29 22:09:03 +02:00
Mike Bayer 452525ac55 Version 2.0.43 placeholder 2025-07-29 08:48:27 -04:00
Mike Bayer b2fcb347cd - 2.0.42 rel_2_0_42 2025-07-29 07:36:14 -04:00
Mike Bayer ff19b715c3 repair changelog file
Change-Id: I40994de5197271060e97a0bd7bccafc7c08918d8
(cherry picked from commit d02a9f9230)
2025-07-29 07:35:37 -04:00
Michael Bayer a7cb3159e6 Merge "Add `dataclass_metadata` parameter to orm cols" into rel_2_0 2025-07-29 11:25:19 +00:00
Federico Caselli d3215624c5 Fix reflection of enum named intervalsomething
Fixes bug that would mistakenly interpret a domain or enum type
with name starting in ``interval`` as an ``INTERVAL`` type while
reflecting a table.

Fixes: #12744
Change-Id: I89ab287c3847ca545691afe73f26d86bf2337ae0
(cherry picked from commit 0620f7d352)
2025-07-28 18:41:03 +02:00
Federico Caselli 45299c3d93 Merge "Add orderinglist type annotations" into rel_2_0 2025-07-28 12:29:33 +00:00
Federico Caselli 90b6f582f8 Merge "type aiosqlite" into rel_2_0 2025-07-28 12:05:15 +00:00
Martijn Pieters e9514b6d8f Add orderinglist type annotations
Closes: #10889
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10889
Pull-request-sha: 2ddeeb1906

Change-Id: I9a0d6e2776d8b6756af4a3c54668bdcd1a1f40f8
(cherry picked from commit 70c918a9be714d46f59c333f8b791cb7864f9531)
2025-07-27 23:09:10 +02:00
Denis Laxalde a6c393fb21 Fix rendering of a SQL example in indexable examples (#12751)
(cherry picked from commit fc2debe97e)
2025-07-26 18:03:24 +02:00
KapilDagur 78c9cd2358 typing: improve type coverage in sql.base
improve type coverage in `sqlalchemy.sql.base`

References: #6810
Closes: #12707
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12707
Pull-request-sha: 7374212dfc

Change-Id: Ied0676f420bc27ae033f0a5e6e22d806d20f4404
(cherry picked from commit ab3de7b0800a17927e09de6d570b906303897c58)
2025-07-22 22:40:32 +02:00
Sigmund Lahn acf6cecd18 Add `dataclass_metadata` parameter to orm cols
Added ``dataclass_metadata`` argument to a all column functions
used in the ORM that accept dataclasses parameters.
It's passed to the underlying dataclass ``metadata`` attribute
of the dataclass field.
Pull request courtesy Sigmund Lahn.

Fixes: #10674
Closes: #12619
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12619
Pull-request-sha: 9ea6a95b2b

Change-Id: I4551c24b85cebee4064df6ab752d0700f0f191f1
(cherry picked from commit aeb7830d22)
2025-07-20 11:09:42 +02:00
Mike Bayer c80ac3fbbb expand out type map example to include the common MySQL case
References: #12742
Change-Id: I9d56597f12141bc8a63665b3cedb5c662a4f5c9d
(cherry picked from commit 632d8e4727)
2025-07-18 12:52:02 -04:00
Victor Tsang adc1b23014 Updated index.rst in dialects docs to include Amazon Aurora DSQL (#12737)
Co-authored-by: Victor Tsang <vitsangp@amazon.com>
(cherry picked from commit c145158821)
2025-07-17 21:03:25 +02:00
Federico Caselli 60105f6bbf add recursive test to values cte
Change-Id: I544aab7f9f5d2640fc6c3d970d835a6e3f80d746
(cherry picked from commit 320c3b5b04)
2025-07-15 22:52:32 +02:00
Mike Bayer 840390ae28 remove py 3.9, 3.8 from mypy job
both were already removed for pep484.  3.9 is EOL in two months
and latest mypy 1.17 changes are now failing, so just remove

Change-Id: I75d9bf06095da13621e2e3470486e44c9da50176
2025-07-15 16:11:43 -04:00
Mike Bayer 75309efdcd extend Values from HasCTE
The :func:`_sql.values` construct gains a new method :meth:`_sql.Values.cte`,
which allows creation of a named, explicit-columns :class:`.CTE` against an
unnamed ``VALUES`` expression, producing a syntax that allows column-oriented
selection from a ``VALUES`` construct on modern versions of PostgreSQL, SQLite,
and MariaDB.

Fixes: #12734
Change-Id: I4a0146418420cce3cbbda4e50f5eb32206dc696b
(cherry picked from commit 209d1913cc)
2025-07-15 14:27:36 -04:00
Mike Bayer 0482d6916f update for mypy 17
note for the 2.0 backport I also updated tox.ini to use mypy 1.17
for the "mypy" suite, 2.1 had this but 2.0 was pinned so some old
mypy version.

Change-Id: I25708115b44bf46d22a2a81fe010db875a8bcb22
(cherry picked from commit b319787b41)
2025-07-14 21:57:32 -04:00
Mike Bayer 0f2702caba support JSONB subscripting syntax
Added support for PostgreSQL 14+ JSONB subscripting syntax. When connected
to PostgreSQL 14 or later, JSONB columns now automatically use the native
subscript notation ``jsonb_col['key']`` instead of the arrow operator
``jsonb_col -> 'key'`` for both read and write operations. This provides
better compatibility with PostgreSQL's native JSONB subscripting feature
while maintaining backward compatibility with older PostgreSQL versions.
JSON columns continue to use the traditional arrow syntax regardless of
PostgreSQL version.

Fixes: #10927
Change-Id: I4b3a8a55a71f2ca3d95416a7b350b785574631eb
(cherry picked from commit 2ac0c45966)
2025-07-13 11:58:58 -04:00
Mike Bayer 96b11c3ba4 block mariadb-connector 1.1.13 and above (tox only)
New segfault occurs under failure modes [1]

[1] https://jira.mariadb.org/browse/CONPY-318

Change-Id: I85dee53be0cb4644c9e500fbb15f7cb35051ff4b
(cherry picked from commit 66d894f265)
2025-07-12 11:35:21 -04:00
Matthew Martin 151c5579e3 docs: Clarify Mapped accepts equivalents to Optional (#12622)
Co-authored-by: Matthew Martin <mmartin@booliproject.com>
(cherry picked from commit 606a979719)
2025-07-12 12:34:55 +02:00
Federico Caselli 7b9365cf90 Re-raise `CancelledError` in asyncpg
Re-raise catched ``CancelledError`` in the terminate method of the
asyncpg dialect to avoid possible hangs of the code execution.

Fixes: #12728
Change-Id: Ia9a353ac7504592be00355001ef40b13ab51375c
(cherry picked from commit 36da2eaf3e)
2025-07-11 00:24:06 +02:00
Evgeny Petrov ccc4d54b5e Make __aiter__ in AsyncTupleReulst a sync function. (#12726)
As it should be accotring to PEP 525

(cherry picked from commit 46c507fb31)
2025-07-10 22:10:54 +02:00
Roman Mashevskyi e60d68f000 Fix the code examples and the grammatic in declarative_tables.rst (#12721)
* Fix the code example in `declarative_tables.rst`

Add an import of a `Optional` class from the `typing` library in the
code example of the "Union types inside the Type Map" chapter.

* Fix the code example in `declarative_tables.rst`

Replace the import of the `deferred` function to `column_property` from
the `sqlalchemy.orm` package in first code example of the "Applying
Load, Persistence and Mapping Options for Imperative Table Columns"
chapter.

* Fix the grammatic in `declarative_tables.rst`

Remove the unnecessary article in the second paragraph of the
"Mapping to an Explicit Set of Primary Key Columns" chapter in
`declarative_tables.rst`.

(cherry picked from commit 75163df8ef)
2025-07-07 22:24:27 +02:00
Sillocan f183d70d1b chore: Fix typo in autoflush warning (#12713)
(cherry picked from commit 7376cdf43e)
2025-07-02 23:21:52 +02:00
Mike Bayer 7268ad96d7 note that SQL parenthesis are based on precedence
References: #12708
Change-Id: I2401e92c936eb01a64ad6896a86faec1c205bc08
(cherry picked from commit 5b5db1f5f3)
2025-07-02 09:20:47 -04:00
Michael Bayer de6c229056 Merge "Update association examples to Declarative API" into rel_2_0 2025-06-30 14:35:15 +00:00
Pablo Estevez 688f136fa2 type aiosqlite
Closes: #12656
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12656
Pull-request-sha: 396e9cfaac

Change-Id: I598ee6022616f265824291544750e571eaba413c
(cherry picked from commit 944df50e92)
2025-06-27 22:13:56 +02:00
Federico Caselli d079ab21e4 remove support for list of tuples in the normal execute
The function that validates the arguments in the normal execute flow
allowed by mistake list of tuples, that are not supported by the
code since the 2.0 series.

Change-Id: Ia401b0e19e72ed33b7d3d5718578cbed0d214c2a
(cherry picked from commit 7a96d2792d)
2025-06-26 21:57:42 +02:00
Mike Fiedler 42915eae74 Update association examples to Declarative API
### Description

Follows initial attempt in #10450 - but starts with simpler association examples.

### Checklist
This pull request is:

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

I was curious how to add these selectively to any of the type hint test suites, to prevent future drift, but didn't see anything too obvious.

Closes: #12031
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12031
Pull-request-sha: dad6239370

Change-Id: Id5c2d65137c5e9d7e87778acd51b965c2bcf315a
(cherry picked from commit 904541a55c)
2025-06-26 21:18:37 +02:00
Michael Bayer 3d448c078e Merge "Deprecate the declarative_mixin decorator" into rel_2_0 2025-06-26 15:22:40 +00:00
Michael Bayer fe01e0af3e Merge "add example to update from that uses values" into rel_2_0 2025-06-24 22:28:30 +00:00
Mike Bayer 265c402322 use zzzeeksphinx 1.6.1 and we arent' really using this doc mod
Change-Id: Ib53111444598331290bde1788f5f2617562d250c
(cherry picked from commit 5394c75bca)
2025-06-24 18:27:11 -04:00
Federico Caselli 156c057aa0 add example to update from that uses values
Change-Id: Ic02a722be9a30851a87e0da4759c728e86fb22c8
References: #11768
(cherry picked from commit fb5e64c51a)
2025-06-24 17:44:05 -04:00
Michael Bayer 1050472235 Merge "try flake8-import-order 0.19.2" into rel_2_0 2025-06-24 20:52:18 +00:00
Mike Bayer ed5237e6a4 try flake8-import-order 0.19.2
the big new thang is that it is doing import order checks inside of
TYPE_CHECKING blocks.   Introduces some new codes that we
enthusiastically add to our ignore list.   update to the latest
and greatest zimports 0.6.2 as well

Change-Id: I4e844408a8b218f9b92c43ad5e2a5c16781100be
(cherry picked from commit 1c83435761)
2025-06-24 14:17:29 -04:00
Mike Bayer f1b6be1bd8 hardening against inappropriate multi-table updates
Hardening of the compiler's actions for UPDATE statements that access
multiple tables to report more specifically when tables or aliases are
referenced in the SET clause; on cases where the backend does not support
secondary tables in the SET clause, an explicit error is raised, and on the
MySQL or similar backends that support such a SET clause, more specific
checking for not-properly-included tables is performed.  Overall the change
is preventing these erroneous forms of UPDATE statements from being
compiled, whereas previously it was relied on the database to raise an
error, which was not always guaranteed to happen, or to be non-ambiguous,
due to cases where the parent table included the same column name as the
secondary table column being updated.

Fixed bug where the ORM would pull in the wrong column into an UPDATE when
a key name inside of the :meth:`.ValuesBase.values` method could be located
from an ORM entity mentioned in the statement, but where that ORM entity
was not the actual table that the statement was inserting or updating.  An
extra check for this edge case is added to avoid this problem.

Fixes: #12692
Change-Id: I342832b09dda7ed494caaad0cbb81b93fc10fe18
(cherry picked from commit dc0d081762)
2025-06-24 10:19:55 -04:00