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)
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)
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)
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)
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)
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)
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: #10674Closes: #12619
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12619
Pull-request-sha: 9ea6a95b2b
Change-Id: I4551c24b85cebee4064df6ab752d0700f0f191f1
(cherry picked from commit aeb7830d22)
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
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)
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)
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)
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)
* 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)
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)
### 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)
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)
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)