]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
10 hours agoMerge "Fix get_columns sqlite reflection rejecting tables with WITHOUT_ROWID and... main
Michael Bayer [Mon, 15 Sep 2025 21:55:45 +0000 (21:55 +0000)] 
Merge "Fix get_columns sqlite reflection rejecting tables with WITHOUT_ROWID and/or STRICT for generated column case" into main

10 hours agoRevert "add RegistryEvents"
Mike Bayer [Mon, 15 Sep 2025 21:26:29 +0000 (17:26 -0400)] 
Revert "add RegistryEvents"

This reverts commit 7111dc0cbaae2070173e9f4a054745ee7d036dfa.

Review had 18 comments still open

18 hours agoFix get_columns sqlite reflection rejecting tables with WITHOUT_ROWID and/or STRICT...
Tip ten Brink [Mon, 15 Sep 2025 12:58:40 +0000 (08:58 -0400)] 
Fix get_columns sqlite reflection rejecting tables with WITHOUT_ROWID and/or STRICT for generated column case

Fixed issue where SQLite table reflection would fail for tables using
``WITHOUT ROWID`` and/or ``STRICT`` table options when the table contained
generated columns. The regular expression used to parse ``CREATE TABLE``
statements for generated column detection has been updated to properly
handle these SQLite table options that appear after the column definitions.
Pull request courtesy Tip ten Brink.

Fixes: #12864
Closes: #12865
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12865
Pull-request-sha: 833420afc72f1918a9ca315209ce6664a18ba07f

Change-Id: Ia25c05746055a66234531b4f1275bd3a2f3b44ad

18 hours agoMerge "add RegistryEvents" into main
Michael Bayer [Mon, 15 Sep 2025 13:42:17 +0000 (13:42 +0000)] 
Merge "add RegistryEvents" into main

2 days agoremove confusing "with_parent()" from query-enabled properties example
Mike Bayer [Sat, 13 Sep 2025 13:54:38 +0000 (09:54 -0400)] 
remove confusing "with_parent()" from query-enabled properties example

references: #12862
Change-Id: I22ee9fa0c566458a465867e307a77c2eb0ddcdd0

3 days agodo the mypy dance
Mike Bayer [Fri, 12 Sep 2025 23:01:31 +0000 (19:01 -0400)] 
do the mypy dance

version 1.18.1.  lots of i have no idea situations.
just add ignores, seems pretty pointless

Change-Id: Ieb1466df3f45fa6b8d11ccd36c7164645740ba35

5 days agoAdd function mapped_as_dataclass
Mike Bayer [Tue, 9 Sep 2025 19:16:45 +0000 (15:16 -0400)] 
Add function mapped_as_dataclass

Added new decorator :func:`_orm.mapped_as_dataclass`, which is a function
based form of :meth:`_orm.registry.mapped_as_dataclass`; the method form
:meth:`_orm.registry.mapped_as_dataclass` does not seem to be correctly
recognized within the scope of :pep:`681` in recent mypy versions.

The new function is tested and mentioned in the docs, in 2.1 in a
subsequent patch (probably the one that adds unmapped_dataclass also)
we'll switch this new decorator to be the prominent one.

also alphabetize mapping_api.rst.  while the summary box at the top
auto-sorts, have the sidebar alpha also, it's kind of weird how
these were in no order at all

Fixes: #12855
Change-Id: If98724fd466004ec4c8a312a0cbf1c934a6ce9e3

6 days agoadd RegistryEvents
Mike Bayer [Sun, 31 Aug 2025 22:53:01 +0000 (18:53 -0400)] 
add RegistryEvents

Added :class:`_orm.RegistryEvents` event class that allows event listeners
to be established on a :class:`_orm.registry` object. The new class
provides three events: :meth:`_orm.RegistryEvents.resolve_type_annotation`
which allows customization of type annotation resolution that can
supplement or replace the use of the
:paramref:`.registry.type_annotation_map` dictionary, including that it can
be helpful with custom resolution for complex types such as those of
:pep:`695`, as well as :meth:`_orm.RegistryEvents.before_configured` and
:meth:`_orm.RegistryEvents.after_configured`, which are registry-local
forms of the mapper-wide version of these hooks.

Fixes: #9832
Change-Id: I32b55de8625ec435edf916a91e65f61fda50cd51

9 days agodoc updates, localize test fixtures
Mike Bayer [Sun, 7 Sep 2025 00:20:00 +0000 (20:20 -0400)] 
doc updates, localize test fixtures

testing with types is inherently awkward and subject
to changes in python interpreters (such as all the recent python 3.14
stuff we had them fix), but in this suite we already have a lot of
types that are defined inline inside of test methods.   so since that's
how many of the tests work anyway, organize the big series of pep-695
and pep-593 structures into fixtures or individual tests to make
the whole suite easier to follow.   pyright complains quite a lot
about this, so if this becomes a bigger issue for say mypy /pep484
target, we may have to revisit (which I'd likely do with more ignores)
or if function/method-local type declarations with global becomes a runtime
issue in py3.15 or something, we can revisit then where we would in
theory need to convert the entire suite, which I'd do with a more
consistent naming style for everything.

but for now try to go with fixtures / local type declarations so that
we dont have to wonder where all these types are used.

Change-Id: Ibe8f447eaa10f5e927b1122c8b608f11a5f5bc97

9 days agoMerge "liberalize pep695 matching" into main
Michael Bayer [Sat, 6 Sep 2025 22:58:23 +0000 (22:58 +0000)] 
Merge "liberalize pep695 matching" into main

9 days agoliberalize pep695 matching
Mike Bayer [Thu, 4 Sep 2025 01:44:33 +0000 (21:44 -0400)] 
liberalize pep695 matching

after many days of discussion we are moving to liberalize the
matching rules used for pep695 to the simple rule that we will resolve
a pep695 type to its immediate ``__value__`` without requiring that
it be present in the type map, however without any further recursive
checks (that is, we will not resolve ``__value__`` of ``__value__``).
This allows the vast majority of simple uses of pep695 types to not
require entries in the type map, including when the type points
to a simple Python type or any type that is present in the type_map.
Also supported is resolution of generic pep695 types against the
right side, including for Annotated types.

The change here in 2.1 will form the base for a revised approach
to the RegistryEvents patch for #9832, which will still provide
the RegistryEvents.resolve_type_annotation hook.   In 2.0, we need
to scale back the warnings that are emitted so portions of this patch
will also be backported including similar changes to the test suite.

Fixes: #12829
Change-Id: Ib6e379793335da3f33f6ca2cd6874a6eaf1e36f4

10 days agointerpret NULL in PG enum array values
Mike Bayer [Fri, 5 Sep 2025 13:29:34 +0000 (09:29 -0400)] 
interpret NULL in PG enum array values

Fixed issue where selecting an enum array column containing NULL values
would fail to parse properly in the PostgreSQL dialect. The
:func:`._split_enum_values` function now correctly handles NULL entries by
converting them to Python ``None`` values.

Fixes: #12847
Change-Id: I39d10bc1be6b458da7e5d3f4b740f8faafd0adc5

12 days agoremove upfront sanitization of entities from joins
Mike Bayer [Tue, 2 Sep 2025 16:26:06 +0000 (12:26 -0400)] 
remove upfront sanitization of entities from joins

ORM entities can now be involved within the SQL expressions used within
:paramref:`_orm.relationship.primaryjoin` and
:paramref:`_orm.relationship.secondaryjoin` parameters without the ORM
entity information being implicitly sanitized, allowing ORM-specific
features such as single-inheritance criteria in subqueries to continue
working even when used in this context.   This is made possible by overall
ORM simplifications that occurred as of the 2.0 series.  The changes here
also provide a performance boost (up to 20%) for certain query compilation
scenarios.

Here we see that we're not only able to remove the
relationships deannotation steps, but we can also change
context -> _get_current_adapter() to be an unconditional
adapter, since the only remaining case where it was conditional
was the polymorphic_adapter.  that adapter is itself
only used for exotic joined inh cases against select
statements (totally not used by anyone) or by abstract
concrete setups.   That lets us remove a whole host
of orm_annotate stuff that doesn't apply anymore.

if this does lead to user regressions in 2.1 it will be
a good reason for us to revisit the complexity here in
any case.

Fixes: #12843
Change-Id: Ic1c6e72d70ec6a27b73495c1a56e9307c9280133

13 days agomove callcount tests to py313, 314
Mike Bayer [Tue, 2 Sep 2025 21:11:31 +0000 (17:11 -0400)] 
move callcount tests to py313, 314

Some other gerrits are making changes to callcounts
so modernize these first

Change-Id: If2125883e36146bfdae8b2e29c0db537985750ac

13 days agosupport omission of standard event listen example
Mike Bayer [Tue, 2 Sep 2025 15:10:51 +0000 (11:10 -0400)] 
support omission of standard event listen example

The required targets for before_configured() and after_configured()
are the Mapper (and soon to include registry things as well in 2.1),
update the automatic doc example thing to be able to be skipped
when there are special instructions for the target.

Also updates the event docs a bit, which were very old and
written in more of that "disorganized wall of details" style
that was very hard to unlearn

Change-Id: I729d08e25b721f4c993aa1856038b27643fc95d0

2 weeks agoMerge "warn on failed aliased" into main
Michael Bayer [Sun, 31 Aug 2025 21:10:53 +0000 (21:10 +0000)] 
Merge "warn on failed aliased" into main

2 weeks agowarn on failed aliased
Mike Bayer [Fri, 8 Aug 2025 16:17:16 +0000 (12:17 -0400)] 
warn on failed aliased

The :func:`_orm.aliased` object now emits warnings when an attribute is
accessed on an aliased class that cannot be located in the target
selectable, for those cases where the :func:`_orm.aliased` is against a
different FROM clause than the regular mapped table (such as a subquery).
This helps users identify cases where column names don't match between the
aliased class and the underlying selectable. When
:paramref:`_orm.aliased.adapt_on_names` is ``True``, the warning suggests
checking the column name; when ``False``, it suggests using the
``adapt_on_names`` parameter for name-based matching.

Fixes: #12838
Change-Id: I4294b57f24dd3fd7741e0bcbd9b521c841ace903

2 weeks agoMerge "add session-wide execution_options" into main
Michael Bayer [Sun, 31 Aug 2025 14:42:30 +0000 (14:42 +0000)] 
Merge "add session-wide execution_options" into main

2 weeks agoMerge "add OperatorClasses to gate mismatched operator use" into main
Michael Bayer [Sun, 31 Aug 2025 14:18:56 +0000 (14:18 +0000)] 
Merge "add OperatorClasses to gate mismatched operator use" into main

2 weeks agoadd session-wide execution_options
Mike Bayer [Tue, 26 Aug 2025 20:54:39 +0000 (16:54 -0400)] 
add session-wide execution_options

Added support for per-session execution options that are merged into all
queries executed within that session. The :class:`_orm.Session`,
:class:`_orm.sessionmaker`, :class:`_orm.scoped_session`,
:class:`_ext.asyncio.AsyncSession`, and
:class:`_ext.asyncio.async_sessionmaker` constructors now accept an
:paramref:`_orm.Session.execution_options` parameter that will be applied
to all explicit query executions (e.g. using :meth:`_orm.Session.execute`,
:meth:`_orm.Session.get`, :meth:`_orm.Session.scalars`) for that session
instance.

Fixes: #12659
Change-Id: I6e19e1567e0c04df32ba1d43baf420fb762f155c

2 weeks agoMerge "use fixture_session() fixture, remove "future" terminology" into main
Michael Bayer [Wed, 27 Aug 2025 00:31:55 +0000 (00:31 +0000)] 
Merge "use fixture_session() fixture, remove "future" terminology" into main

2 weeks agoMerge "use _generate_columns_plus_names for ddl returning c populate" into main
Michael Bayer [Wed, 27 Aug 2025 00:14:57 +0000 (00:14 +0000)] 
Merge "use _generate_columns_plus_names for ddl returning c populate" into main

2 weeks agouse fixture_session() fixture, remove "future" terminology
Mike Bayer [Tue, 26 Aug 2025 23:14:20 +0000 (19:14 -0400)] 
use fixture_session() fixture, remove "future" terminology

Tests here are sporadically failing on aiosqlite and it
seems the use of Session() rather than fixture_session() may be
causing connections to be cleaned up in GC, leading to table
exists race conditions.

Remove the concept of "future" since everything is "future" now

Change-Id: Ibf9ec8c47d3ab4ce95566811c9f6729ddd78a7d3

2 weeks agoMerge "Create terminate mixin" into main
Michael Bayer [Tue, 26 Aug 2025 22:21:07 +0000 (22:21 +0000)] 
Merge "Create terminate mixin" into main

2 weeks agouse _generate_columns_plus_names for ddl returning c populate
Mike Bayer [Tue, 26 Aug 2025 18:47:34 +0000 (14:47 -0400)] 
use _generate_columns_plus_names for ddl returning c populate

Improved the implementation of :meth:`.UpdateBase.returning` to use more
robust logic in setting up the ``.c`` collection of a derived statement
such as a CTE.  This fixes issues related to RETURNING clauses that feature
expressions based on returned columns with or without qualifying labels.

Co-authored-by: Juhyeong Ko <dury.ko@gmail.com>
Fixes: #12271
Change-Id: Id0d486d4304002f1affdec2e7662ac2965936f2a

2 weeks agosupport configurable None behavior for composites
Mike Bayer [Mon, 5 May 2025 12:36:05 +0000 (08:36 -0400)] 
support configurable None behavior for composites

Added new parameter :paramref:`_orm.composite.return_none_on` to
:func:`_orm.composite`, which allows control over if and when this
composite attribute should resolve to ``None`` when queried or retrieved
from the object directly.  By default, a composite object is always present
on the attribute, including for a pending object which is a behavioral
change since 2.0.   When :paramref:`_orm.composite.return_none_on` is
specified, a callable is passed that returns True or False to indicate if
the given arguments indicate the composite should be returned as None. This
parameter may also be set automatically when ORM Annotated Declarative is
used; if the annotation is given as ``Mapped[SomeClass|None]``, a
:paramref:`_orm.composite.return_none_on` rule is applied that will return
``None`` if all contained columns are themselves ``None``.

Fixes: #12570
Change-Id: Iab01ac46065689da1332c9f80dedbc7eb0f5380b

3 weeks agoadd OperatorClasses to gate mismatched operator use
Mike Bayer [Wed, 16 Jul 2025 16:14:27 +0000 (12:14 -0400)] 
add OperatorClasses to gate mismatched operator use

Added a new concept of "operator classes" to the SQL operators supported by
SQLAlchemy, represented within the enum :class:`.OperatorClass`.  The
purpose of this structure is to provide an extra layer of validation when a
particular kind of SQL operation is used with a particular datatype, to
catch early the use of an operator that does not have any relevance to the
datatype in use; a simple example is an integer or numeric column used with
a "string match" operator.

Fixes: #12736
Change-Id: I44f46d7326aef6847dbf0cf7a325833f8e347da6

3 weeks agoMerge "more extensibility for asc/desc" into main
Michael Bayer [Mon, 25 Aug 2025 15:37:24 +0000 (15:37 +0000)] 
Merge "more extensibility for asc/desc" into main

3 weeks agoMerge "ensure datatype roundtrips for JSON dialects" into main
Michael Bayer [Mon, 25 Aug 2025 15:36:54 +0000 (15:36 +0000)] 
Merge "ensure datatype roundtrips for JSON dialects" into main

3 weeks agoensure datatype roundtrips for JSON dialects
Mike Bayer [Fri, 22 Aug 2025 22:12:13 +0000 (18:12 -0400)] 
ensure datatype roundtrips for JSON dialects

Improved the behavior of JSON accessors :meth:`.JSON.Comparator.as_string`,
:meth:`.JSON.Comparator.as_boolean`, :meth:`.JSON.Comparator.as_float`,
:meth:`.JSON.Comparator.as_integer` to use CAST in a similar way that
the PostgreSQL, MySQL and SQL Server dialects do to help enforce the
expected Python type is returned.

The :meth:`.JSON.Comparator.as_boolean` method when used on a JSON value on
SQL Server will now force a cast to occur for values that are not simple
`true`/`false` JSON literals, forcing SQL Server to attempt to interpret
the given value as a 1/0 BIT, or raise an error if not possible. Previously
the expression would return NULL.

Fixes: #11074
Change-Id: I5024b78ec2fa6b61a9c6ee176112f1b761eeab98

3 weeks agoMerge "remove python 3.9 support since it's close to eol" into main
Michael Bayer [Mon, 25 Aug 2025 13:50:43 +0000 (13:50 +0000)] 
Merge "remove python 3.9 support since it's close to eol" into main

3 weeks agoremove python 3.9 support since it's close to eol
Federico Caselli [Thu, 21 Aug 2025 20:53:15 +0000 (22:53 +0200)] 
remove python 3.9 support since it's close to eol

Fixes: #12819
Change-Id: I60f848226c1fef2a769845938d6afa3d3c5d0509

3 weeks agomore extensibility for asc/desc
Mike Bayer [Tue, 29 Jul 2025 18:19:34 +0000 (14:19 -0400)] 
more extensibility for asc/desc

Improved the behavior of standalone "operators" like :func:`_sql.desc`,
:func:`_sql.asc`, :func:`_sql.all_`, etc. so that they consult the given
expression object for an overriding method for that operator, even if the
object is not itself a ``ClauseElement``, such as if it's an ORM attribute.
This allows custom comparators for things like :func:`_orm.composite` to
provide custom implementations of methods like ``desc()``, ``asc()``, etc.

Added default implementations of :meth:`.ColumnOperators.desc`,
:meth:`.ColumnOperators.asc`, :meth:`.ColumnOperators.nulls_first`,
:meth:`.ColumnOperators.nulls_last` to :func:`_orm.composite` attributes,
by default applying the modifier to all contained columns.  Can be
overridden using a custom comparator.

Fixes: #12769
Change-Id: I055ce79bf7ac31fb61d48bc3ab34799d42fb6336

3 weeks agoMerge "ensure assoc proxy from aliased() is generated in correct context" into main
Michael Bayer [Fri, 22 Aug 2025 17:07:13 +0000 (17:07 +0000)] 
Merge "ensure assoc proxy from aliased() is generated in correct context" into main

3 weeks agoensure assoc proxy from aliased() is generated in correct context
Mike Bayer [Thu, 21 Aug 2025 15:20:11 +0000 (11:20 -0400)] 
ensure assoc proxy from aliased() is generated in correct context

Improved association proxy to behave slightly better when the parent class
is used in an :func:`_orm.aliased` construct, so that the proxy as
delivered by the :class:`.Aliased` behaves appropriate in terms of that
aliased construct, including operators like ``.any()`` and ``.has()`` work
correctly.

Fixes: #11622
Change-Id: I6220d984d4323a01a38bd89cfbb1bae46d81c24e

3 weeks agoAdd arm64 wheel builds and tests (#12816)
Finn Womack [Thu, 21 Aug 2025 19:54:28 +0000 (12:54 -0700)] 
Add arm64 wheel builds and tests (#12816)

* add windows-11-arm tests

* add windows-11-arm builds

* add workflow fork trigger

* add fork branch push trigger

* remove fork trigger

* remove fork trigger

* Add comment

3 weeks agoFix typing for `hybrid_property.__set__` to properly validate setter values
Micah Denbraver [Wed, 20 Aug 2025 20:58:02 +0000 (16:58 -0400)] 
Fix typing for `hybrid_property.__set__` to properly validate setter values

While iterating on some typing improvements, my colleague @seamuswn pointed out mypy wasn't catching when values with invalid types were set using a `hybrid_property` setter. I believe this is all that's needed to fix the typing.

### Description
Adjust `hybrid_property.__set__` to expect a value of the type that matches the generic's type variable.

### 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: #12814
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12814
Pull-request-sha: 8a17b26aea264acf70c52de324b8ccb92b469f2d

Change-Id: Ic99ccc68a32354ef6fe013ec17242058ad2d6d63

3 weeks agoMerge "restore functionality in list" into main
Federico Caselli [Tue, 19 Aug 2025 17:26:25 +0000 (17:26 +0000)] 
Merge "restore functionality in list" into main

4 weeks agoCreate terminate mixin
Federico Caselli [Thu, 23 Jan 2025 21:42:14 +0000 (22:42 +0100)] 
Create terminate mixin

Generalize the terminate logic employed by the asyncpg dialect to reuse
it in the aiomysql and asyncmy dialect implementation.

Fixes: #12273
Change-Id: Iddb658b7118de774f169e31e888a8aae1c7c6ec2

4 weeks agorestore functionality in list
Federico Caselli [Thu, 14 Aug 2025 22:05:07 +0000 (00:05 +0200)] 
restore functionality in list

Fixed issue caused by an unwanted functional change while typing
the :class:`.MutableList` class.
This change also reverts all other functional changes done in
the same change, commit ba0e508141206efc55cdab91df21c18e7dd63c80

Fixes: #12802
Change-Id: I007aa86aec881241ea42ce59d1b078cf8c6829bb

4 weeks agoWe can't promise CursorResult from session.execute()
Mike Bayer [Mon, 18 Aug 2025 15:01:47 +0000 (11:01 -0400)] 
We can't promise CursorResult from session.execute()

Fixed typing bug where the :meth:`.Session.execute` method advertised that
it would return a :class:`.CursorResult` if given an insert/update/delete
statement.  This is not the general case as several flavors of ORM
insert/update do not actually yield a :class:`.CursorResult` which cannot
be differentiated at the typing overload level, so the method now yields
:class:`.Result` in all cases.  For those cases where
:class:`.CursorResult` is known to be returned and the ``.rowcount``
attribute is required, please use ``typing.cast()``.

Fixes: #12813
Change-Id: I8a7197100db312b3898c66ceddd6638e68c6bb44

4 weeks agohttphost string
Mike Bayer [Sat, 16 Aug 2025 13:58:07 +0000 (09:58 -0400)] 
httphost string

Change-Id: I056c3c5e68b41060125d670de35c53fa550c36ca

4 weeks agouse ssh host
Mike Bayer [Sat, 16 Aug 2025 13:41:58 +0000 (09:41 -0400)] 
use ssh host

Change-Id: I7fafc3c8b48c042bf63c31ef697cfa6dad8bca97

4 weeks agoclose aio cursors etc. that require await close
Mike Bayer [Tue, 12 Aug 2025 19:25:15 +0000 (15:25 -0400)] 
close aio cursors etc. that require await close

Improved the base implementation of the asyncio cursor such that it
includes the option for the underlying driver's cursor to be actively
closed in those cases where it requires ``await`` in order to complete the
close sequence, rather than relying on garbage collection to "close" it,
when a plain :class:`.Result` is returned that does not use ``await`` for
any of its methods.  The previous approach of relying on gc was fine for
MySQL and SQLite dialects but has caused problems with the aioodbc
implementation on top of SQL Server.   The new option is enabled
for those dialects which have an "awaitable" ``cursor.close()``, which
includes the aioodbc, aiomysql, and asyncmy dialects (aiosqlite is also
modified for 2.1 only).

Fixes: #12798
Change-Id: Ib17d611201fedf9780dfe3d760760ace99a8835c

5 weeks agocherry-pick changelog update for 2.0.44
Mike Bayer [Mon, 11 Aug 2025 14:25:16 +0000 (10:25 -0400)] 
cherry-pick changelog update for 2.0.44

5 weeks agocherry-pick changelog from 2.0.43
Mike Bayer [Mon, 11 Aug 2025 14:25:16 +0000 (10:25 -0400)] 
cherry-pick changelog from 2.0.43

5 weeks agomaintain alphabetical create_engine() param ordering
Mike Bayer [Mon, 11 Aug 2025 14:19:12 +0000 (10:19 -0400)] 
maintain alphabetical create_engine() param ordering

the name changed on this so it needs to be moved down

Change-Id: I119c3f5db9262c80b6dd2175e1e56073776607cf

5 weeks agodoc fixes
Mike Bayer [Mon, 11 Aug 2025 14:15:12 +0000 (10:15 -0400)] 
doc fixes

Change-Id: Iee65f09ea17bfa7a39fe3da05f22007f92b76f29

5 weeks agoFixes: #12711 Added sparse vector support in Oracle
suraj [Mon, 11 Aug 2025 12:21:46 +0000 (08:21 -0400)] 
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: 5a4199de1e89785129ee6fce4c7e65570419a1c7

Change-Id: Icdda9520a5f752e923f087edb166b4032f5bfd21

5 weeks agoensure autocommit is not False for SQLite FK pragma
Mike Bayer [Thu, 7 Aug 2025 14:48:51 +0000 (10:48 -0400)] 
ensure autocommit is not False for SQLite FK pragma

References: #12767
References: https://github.com/python/cpython/issues/137205
Change-Id: I6772a4c9c216c6981421043f850cbf833ded2be3

5 weeks agoMerge "implement skip_autocommit_rollback" into main
Michael Bayer [Thu, 7 Aug 2025 14:46:02 +0000 (14:46 +0000)] 
Merge "implement skip_autocommit_rollback" into main

5 weeks agoMerge "add chunking to selectin_polymorphic" into main
Michael Bayer [Wed, 6 Aug 2025 19:19:49 +0000 (19:19 +0000)] 
Merge "add chunking to selectin_polymorphic" into main

5 weeks agoimplement skip_autocommit_rollback
Mike Bayer [Tue, 5 Aug 2025 14:46:21 +0000 (10:46 -0400)] 
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

5 weeks agoadd chunking to selectin_polymorphic
Mike Bayer [Wed, 6 Aug 2025 14:19:39 +0000 (10:19 -0400)] 
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

5 weeks agoMerge "Fix use_existing_column with Annotated mapped_column in polymorphic inheritanc...
Michael Bayer [Wed, 6 Aug 2025 14:39:28 +0000 (14:39 +0000)] 
Merge "Fix use_existing_column with Annotated mapped_column in polymorphic inheritance" into main

5 weeks agoapply correct pre-fetch params to post updated rows
Mike Bayer [Tue, 5 Aug 2025 21:11:50 +0000 (17:11 -0400)] 
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

5 weeks agoand now a word on AI
Mike Bayer [Tue, 5 Aug 2025 19:43:25 +0000 (15:43 -0400)] 
and now a word on AI

Change-Id: Ibec387d36bc08ea40c0e4c92bd5f2f79a54adaf7

5 weeks agoFix use_existing_column with Annotated mapped_column in polymorphic inheritance
Mike Bayer [Tue, 5 Aug 2025 18:05:49 +0000 (14:05 -0400)] 
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

5 weeks agoMerge "Fix PostgreSQL JSONB subscripting regression with functions" into main
Michael Bayer [Tue, 5 Aug 2025 18:13:59 +0000 (18:13 +0000)] 
Merge "Fix PostgreSQL JSONB subscripting regression with functions" into main

6 weeks agoMerge "cleanup implementation of asyncpg connection" into main
Michael Bayer [Mon, 4 Aug 2025 19:47:19 +0000 (19:47 +0000)] 
Merge "cleanup implementation of asyncpg connection" into main

6 weeks agoMerge "generalize composite bulk insert to hybrids" into main
Michael Bayer [Mon, 4 Aug 2025 19:44:36 +0000 (19:44 +0000)] 
Merge "generalize composite bulk insert to hybrids" into main

6 weeks agoMerge "add CRUD column marker" into main
Michael Bayer [Mon, 4 Aug 2025 19:41:56 +0000 (19:41 +0000)] 
Merge "add CRUD column marker" into main

6 weeks agoFix PostgreSQL JSONB subscripting regression with functions
Mike Bayer [Fri, 1 Aug 2025 16:48:15 +0000 (12:48 -0400)] 
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

6 weeks agofix typo in docs
Federico Caselli [Thu, 31 Jul 2025 17:21:33 +0000 (19:21 +0200)] 
fix typo in docs

Change-Id: I327961111c4f785a1a21dfabbf620f9f8f8f5d90

6 weeks agoupdate install faq to align with code
Federico Caselli [Wed, 30 Jul 2025 20:36:35 +0000 (22:36 +0200)] 
update install faq to align with code

Closes #12757

Change-Id: I13b98a185fb4347cd172c6a6f95214672ae05fec

6 weeks agoremove obsolete file
Federico Caselli [Tue, 29 Jul 2025 20:17:27 +0000 (22:17 +0200)] 
remove obsolete file

Remove mypy_plugin.ini file that's no loger useful, since the mypy
plugin was removed in d69765829c9fbc98f21a22dbc496f2b7b22dc52c

Change-Id: I3f49a367b36b07e8cc1b10b415d6209de2eef3fb

6 weeks agoRemove unnecessary r-prefix from docstring in 'columns' method (#12768)
Sviatoslav Bobryshev [Tue, 29 Jul 2025 20:08:15 +0000 (23:08 +0300)] 
Remove unnecessary r-prefix from docstring in 'columns' method (#12768)

6 weeks agocherry-pick changelog update for 2.0.43
Mike Bayer [Tue, 29 Jul 2025 12:48:27 +0000 (08:48 -0400)] 
cherry-pick changelog update for 2.0.43

6 weeks agocherry-pick changelog from 2.0.42
Mike Bayer [Tue, 29 Jul 2025 12:48:27 +0000 (08:48 -0400)] 
cherry-pick changelog from 2.0.42

6 weeks agorepair changelog file
Mike Bayer [Tue, 29 Jul 2025 11:34:56 +0000 (07:34 -0400)] 
repair changelog file

Change-Id: I40994de5197271060e97a0bd7bccafc7c08918d8

6 weeks agoMerge "Add ``dataclass_metadata`` parameter to orm cols" into main
Michael Bayer [Tue, 29 Jul 2025 11:25:12 +0000 (11:25 +0000)] 
Merge "Add ``dataclass_metadata`` parameter to orm cols" into main

6 weeks agoMerge "Fix reflection of enum named intervalsomething" into main
Michael Bayer [Tue, 29 Jul 2025 11:21:12 +0000 (11:21 +0000)] 
Merge "Fix reflection of enum named intervalsomething" into main

7 weeks agoFix reflection of enum named intervalsomething
Federico Caselli [Mon, 21 Jul 2025 21:36:43 +0000 (23:36 +0200)] 
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

7 weeks agoMerge "Add orderinglist type annotations" into main
Federico Caselli [Mon, 28 Jul 2025 12:29:24 +0000 (12:29 +0000)] 
Merge "Add orderinglist type annotations" into main

7 weeks agoMerge "type aiosqlite" into main
Federico Caselli [Mon, 28 Jul 2025 12:05:01 +0000 (12:05 +0000)] 
Merge "type aiosqlite" into main

7 weeks agoAdd orderinglist type annotations
Martijn Pieters [Mon, 25 Nov 2024 19:38:48 +0000 (14:38 -0500)] 
Add orderinglist type annotations

Closes: #10889
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10889
Pull-request-sha: 2ddeeb190630a8965a4fae567e2649ed16722c99

Change-Id: I9a0d6e2776d8b6756af4a3c54668bdcd1a1f40f8

7 weeks agocleanup implementation of asyncpg connection
Federico Caselli [Mon, 24 Mar 2025 21:44:05 +0000 (22:44 +0100)] 
cleanup implementation of asyncpg connection

Change-Id: Ic7ecbeb6341145544b2a501d287e3e1d30fb1cbc

7 weeks agoFix rendering of a SQL example in indexable examples (#12751)
Denis Laxalde [Sat, 26 Jul 2025 16:02:46 +0000 (18:02 +0200)] 
Fix rendering of a SQL example in indexable examples (#12751)

8 weeks agoAdd ``dataclass_metadata`` parameter to orm cols
Sigmund Lahn [Thu, 3 Jul 2025 16:14:13 +0000 (12:14 -0400)] 
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: 9ea6a95b2bc6816e5b69d6d559783a6009877838

Change-Id: I4551c24b85cebee4064df6ab752d0700f0f191f1

8 weeks agoavid importing from primate module
Federico Caselli [Sun, 20 Jul 2025 08:54:32 +0000 (10:54 +0200)] 
avid importing from primate module

Change-Id: Ia1581cf6db0ed2d2f995ef5f40d4cff944252e80

8 weeks agoMerge "typing: improve type coverage in sql.base" into main
Michael Bayer [Sat, 19 Jul 2025 11:12:41 +0000 (11:12 +0000)] 
Merge "typing: improve type coverage in sql.base" into main

8 weeks agoMerge "Improve handling of sentinel columns" into main
Michael Bayer [Sat, 19 Jul 2025 11:09:50 +0000 (11:09 +0000)] 
Merge "Improve handling of sentinel columns" into main

8 weeks agoexpand out type map example to include the common MySQL case
Mike Bayer [Fri, 18 Jul 2025 16:35:27 +0000 (12:35 -0400)] 
expand out type map example to include the common MySQL case

References: #12742
Change-Id: I9d56597f12141bc8a63665b3cedb5c662a4f5c9d

8 weeks agoUpdated index.rst in dialects docs to include Amazon Aurora DSQL (#12737)
Victor Tsang [Thu, 17 Jul 2025 19:02:44 +0000 (12:02 -0700)] 
Updated index.rst in dialects docs to include Amazon Aurora DSQL (#12737)

Co-authored-by: Victor Tsang <vitsangp@amazon.com>
2 months agoadd recursive test to values cte
Federico Caselli [Tue, 15 Jul 2025 20:50:32 +0000 (22:50 +0200)] 
add recursive test to values cte

Change-Id: I544aab7f9f5d2640fc6c3d970d835a6e3f80d746

2 months agoremove py 3.9 from mypy job
Mike Bayer [Tue, 15 Jul 2025 20:10:32 +0000 (16:10 -0400)] 
remove py 3.9 from mypy job

Was 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

2 months agoextend Values from HasCTE
Mike Bayer [Mon, 14 Jul 2025 20:13:03 +0000 (16:13 -0400)] 
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

2 months agotyping: improve type coverage in sql.base
KapilDagur [Mon, 14 Jul 2025 19:36:30 +0000 (15:36 -0400)] 
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: 7374212dfc88a43f381f8380d9b4ac193f5ed10b

Change-Id: Ied0676f420bc27ae033f0a5e6e22d806d20f4404

2 months agoupdate for mypy 17
Mike Bayer [Mon, 14 Jul 2025 22:08:51 +0000 (18:08 -0400)] 
update for mypy 17

Change-Id: I25708115b44bf46d22a2a81fe010db875a8bcb22

2 months agoImprove handling of sentinel columns
Federico Caselli [Fri, 29 Dec 2023 21:30:24 +0000 (22:30 +0100)] 
Improve handling of sentinel columns

Fixed issue in "insertmanyvalues" feature where an INSERT..RETURNING
that also made use of a sentinel column to track results would fail to
filter out the additional column when :meth:`.Result.unique` were used
to uniquify the result set.

Fixes: #10802
Change-Id: Ie4f9dab96193099002088c5219cc41a543a00f62

2 months agoUnconditionally flush session on all statement executions
Mike Bayer [Thu, 10 Jul 2025 19:29:29 +0000 (15:29 -0400)] 
Unconditionally flush session on all statement executions

This change simplifies session execution logic to always run autoflush
for all statement executions, regardless of whether they are ORM or Core
statements. Previously, autoflush was conditionally applied only when
ORM-related statements were detected, which had become difficult to define
clearly with the unified v2 syntax that blurs the lines between Core and
ORM execution patterns.

The implementation adds a call to self._autoflush() in the Core execution
path (when compile_state_cls is None) in Session._execute_internal(),
ensuring consistent autoflush behavior across all types of SQL execution.

This provides more predictable session behavior and eliminates the
confusion around which statements trigger autoflush.

Also included is some improvement to the migration_21 document

Fixes: #9809
Change-Id: I0b1974f1981c8a747a0feaaca74ed45106b2b160

2 months agosupport JSONB subscripting syntax
Mike Bayer [Fri, 11 Jul 2025 16:51:44 +0000 (12:51 -0400)] 
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

2 months agoblock mariadb-connector 1.1.13 and above (tox only)
Mike Bayer [Sat, 12 Jul 2025 15:34:35 +0000 (11:34 -0400)] 
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

2 months agodocs: Clarify Mapped accepts equivalents to Optional (#12622)
Matthew Martin [Sat, 12 Jul 2025 10:34:22 +0000 (05:34 -0500)] 
docs: Clarify Mapped accepts equivalents to Optional (#12622)

Co-authored-by: Matthew Martin <mmartin@booliproject.com>
2 months agoRe-raise ``CancelledError`` in asyncpg
Federico Caselli [Thu, 10 Jul 2025 22:21:54 +0000 (00:21 +0200)] 
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

2 months agogeneralize composite bulk insert to hybrids
Mike Bayer [Thu, 3 Apr 2025 14:36:28 +0000 (10:36 -0400)] 
generalize composite bulk insert to hybrids

Added new hybrid method :meth:`.hybrid_property.bulk_insert_setter` which
works in a similar way as :meth:`.hybrid_property.update_expression` for
bulk ORM operations.  A user-defined class method can now populate a bulk
insert mapping dictionary using the desired hybrid mechanics.   New
documentation is added showing how both of these methods can be used
including in combination with the new :func:`_sql.from_dml_column`
construct.

Fixes: #12496
Change-Id: I39f6793538f14314e0147765fa2d780b7c99493e

2 months agoMake __aiter__ in AsyncTupleReulst a sync function. (#12726)
Evgeny Petrov [Thu, 10 Jul 2025 20:10:08 +0000 (21:10 +0100)] 
Make __aiter__ in AsyncTupleReulst a sync function. (#12726)

As it should be accotring to PEP 525

2 months agoFix the code examples and the grammatic in `declarative_tables.rst` (#12721)
Roman Mashevskyi [Mon, 7 Jul 2025 20:23:43 +0000 (23:23 +0300)] 
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`.

2 months agoadd CRUD column marker
Mike Bayer [Thu, 3 Apr 2025 14:36:28 +0000 (10:36 -0400)] 
add CRUD column marker

Added new Core feature :func:`_sql.from_dml_column` that may be used in
expressions inside of :meth:`.UpdateBase.values` for INSERT or UPDATE; this
construct will copy whatever SQL expression is used for the given target
column in the statement to be used with additional columns. The construct
is mostly intended to be a helper with ORM :class:`.hybrid_property` within
DML hooks.

This is the Core side of the feature being added to the ORM
for #12496

Change-Id: Ic568638a8ce3607deea44af988b6451b30cde36c

2 months agoMerge "support insert of table columns in specific positions" into main
Michael Bayer [Wed, 2 Jul 2025 21:47:59 +0000 (21:47 +0000)] 
Merge "support insert of table columns in specific positions" into main