]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 weeks agoupdates for sphinx build to run correctly
Mike Bayer [Tue, 3 Jun 2025 20:49:45 +0000 (16:49 -0400)] 
updates for sphinx build to run correctly

Change-Id: Ibd3227c57d334200e40f6184a577cf34d1d03cbb

4 weeks agoadd python 3.14 to run-test
Mike Bayer [Tue, 3 Jun 2025 18:28:19 +0000 (14:28 -0400)] 
add python 3.14 to run-test

If I'm reading correctly at https://github.com/actions/python-versions ,
there are plenty of python 3.14 versions available, so this should
"work".

Still not sure about wheel building so leaving that separate

Change-Id: Idd1ce0db124b700091f5499d6a7d087f6e31777e

4 weeks agoMerge "Reflect index's column operator class on PostgreSQL" into main
Michael Bayer [Tue, 3 Jun 2025 18:23:57 +0000 (18:23 +0000)] 
Merge "Reflect index's column operator class on PostgreSQL" into main

4 weeks agoadd future mode tests for MappedAsDataclass; more py314b1 regressions
Mike Bayer [Fri, 9 May 2025 15:50:26 +0000 (11:50 -0400)] 
add future mode tests for MappedAsDataclass; more py314b1 regressions

for py314b2 all issues should be resolved

py314: yes
Change-Id: I498a1f623aeb5eb664289236e01e35d8a3dec99f

4 weeks agoMerge "Fix type errors surfaced by mypy 1.16" into main
Michael Bayer [Tue, 3 Jun 2025 14:14:20 +0000 (14:14 +0000)] 
Merge "Fix type errors surfaced by mypy 1.16" into main

4 weeks agoFix type errors surfaced by mypy 1.16
Federico Caselli [Fri, 30 May 2025 20:53:59 +0000 (22:53 +0200)] 
Fix type errors surfaced by mypy 1.16

Change-Id: I50bbd760577ff7c865c81153041e82bba068e5d8

5 weeks agoMerge "The ``Enum.inherit_schema`` now defaults to true" into main
Michael Bayer [Mon, 2 Jun 2025 17:33:32 +0000 (17:33 +0000)] 
Merge "The ``Enum.inherit_schema`` now defaults to true" into main

5 weeks agoReflect index's column operator class on PostgreSQL
Denis Laxalde [Wed, 28 May 2025 19:37:36 +0000 (15:37 -0400)] 
Reflect index's column operator class on PostgreSQL

Fill the `postgresql_ops` key of PostgreSQL's `dialect_options` returned by get_multi_indexes() with a mapping from column names to the operator class, if it's not the default for respective data type.

As we need to join on ``pg_catalog.pg_opclass``, the table definition is added to ``postgresql.pg_catalog``.

Fixes #8664.

Closes: #12504
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12504
Pull-request-sha: 8fdf93e1b27c371f52990d5fda8b2fdf79ec23eb

Change-Id: I8789c1e9d15f8cc9a7205f492ec730570f19bbcc

5 weeks agoThe ``Enum.inherit_schema`` now defaults to true
Federico Caselli [Sun, 23 Jun 2024 13:01:40 +0000 (15:01 +0200)] 
The ``Enum.inherit_schema`` now defaults to true

Changed the default value of :paramref:`_types.Enum.inherit_schema` to
``True`` when :paramref:`_types.Enum.schema` and
:paramref:`_types.Enum.metadata` parameters are not provided.
The same behavior has been applied also to PostgreSQL
:class:`_postgresql.DOMAIN` type.

Fixes: #10594
Change-Id: Id3d819e3608974353e365cd063d9c5e40a071e73

5 weeks agoMerge "update black to 25.1.0 to align it with alembic" into main
Michael Bayer [Tue, 27 May 2025 19:48:35 +0000 (19:48 +0000)] 
Merge "update black to 25.1.0 to align it with alembic" into main

6 weeks agoMerge "Add missing requires in the tests for older postgresql version" into main
Michael Bayer [Sun, 25 May 2025 14:16:23 +0000 (14:16 +0000)] 
Merge "Add missing requires in the tests for older postgresql version" into main

6 weeks agofix missing quotes from cast call in mysqlconnector module
Federico Caselli [Fri, 23 May 2025 21:10:43 +0000 (23:10 +0200)] 
fix missing quotes from cast call in mysqlconnector module

This fixes an issue introduced by 51a7678db2f0fcb1552afa40333640bc7fbb6dac
in I37bd98049ff1a64d58e9490b0e5e2ea764dd1f73

Change-Id: Id738c04ee4dc8c2b12d9ab0fc71a4e1a6c5bc209

6 weeks agoupdate black to 25.1.0 to align it with alembic
Federico Caselli [Tue, 20 May 2025 20:15:06 +0000 (22:15 +0200)] 
update black to 25.1.0 to align it with alembic

Change-Id: I2ac332237f18bbc44155eadee35c64f62adc2867

6 weeks agoDoc: Update connection / reconnecting_engine (#12617)
François-Michel L'Heureux [Fri, 23 May 2025 20:23:53 +0000 (16:23 -0400)] 
Doc: Update connection / reconnecting_engine (#12617)

6 weeks agodocs: Clarify that relationship() first parameter is positional (#12621)
krave1986 [Fri, 23 May 2025 20:23:00 +0000 (04:23 +0800)] 
docs: Clarify that relationship() first parameter is positional (#12621)

6 weeks agoAdd missing requires in the tests for older postgresql version
Denis Laxalde [Wed, 21 May 2025 07:23:12 +0000 (03:23 -0400)] 
Add missing requires in the tests for older postgresql version

Follow up commit 39bb17442ce6ac9a3dde5e2b72376b77ffce5e28.

Closes: #12612
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12612
Pull-request-sha: 894276ff232ba328cc235ecf04e84067db204c3d

Change-Id: Ib8d47f11e34d6bb40d9a88d5f411c2d5fee70823

6 weeks agoMerge "Use pg_index's indnatts when indnkeyatts is not available" into main
Michael Bayer [Tue, 20 May 2025 21:32:04 +0000 (21:32 +0000)] 
Merge "Use pg_index's indnatts when indnkeyatts is not available" into main

6 weeks agoimprove changelog for ticket:`12479`
Federico Caselli [Tue, 20 May 2025 20:47:39 +0000 (22:47 +0200)] 
improve changelog for ticket:`12479`

Change-Id: I20fd3eabdb3777acd2ff7ffa144367929f2127d5

6 weeks agoUse pg_index's indnatts when indnkeyatts is not available
Denis Laxalde [Tue, 20 May 2025 14:26:14 +0000 (10:26 -0400)] 
Use pg_index's indnatts when indnkeyatts is not available

Using NULL when this column is not available does not work with old PostgreSQL (tested on version 9.6, as reported in #12600).

Instead, use `indnatts` which should be equal to what `indnkeyatts` would be as there is no "included attributes" in the index on these old versions (but only "key columns").

From https://www.postgresql.org/docs/17/catalog-pg-index.html:
* `indnatts`, "The total number of columns in the index [...]; this number includes both key and included attributes"
* `indnkeyatts`, "The number of key columns in the index, not counting any included columns [...]"

Fixes #12600.

Closes: #12611
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12611
Pull-request-sha: 8ff48a6225ec58fdfa84aec75d487238281b1ac1

Change-Id: Idcadcd7db545bc1f73d85b29347c8ba388b1b41d

6 weeks agoMerge "Type mysql dialect" into main
Michael Bayer [Tue, 20 May 2025 14:51:19 +0000 (14:51 +0000)] 
Merge "Type mysql dialect" into main

7 weeks agoMerge "Support `matmul` (@) as an optional operator." into main
Michael Bayer [Tue, 20 May 2025 02:18:02 +0000 (02:18 +0000)] 
Merge "Support `matmul` (@) as an optional operator." into main

7 weeks agoType mysql dialect
Pablo Estevez [Tue, 13 May 2025 13:39:19 +0000 (09:39 -0400)] 
Type mysql dialect

Closes: #12164
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12164
Pull-request-sha: 545e2c39d5ee4f3938111b26e098fa2aa2b6e800
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I37bd98049ff1a64d58e9490b0e5e2ea764dd1f73

7 weeks agoUpdate index.rst in dialects docs to include Denodo (#12604)
Denodo Research Labs [Mon, 19 May 2025 20:19:34 +0000 (22:19 +0200)] 
Update index.rst in dialects docs to include Denodo (#12604)

7 weeks agoMerge "i think we dont need DOMAIN.adapt()" into main
Michael Bayer [Sun, 18 May 2025 14:56:36 +0000 (14:56 +0000)] 
Merge "i think we dont need DOMAIN.adapt()" into main

7 weeks agoMerge "Remove declarative_mixin" into main
Michael Bayer [Fri, 16 May 2025 18:37:43 +0000 (18:37 +0000)] 
Merge "Remove declarative_mixin" into main

7 weeks agoi think we dont need DOMAIN.adapt()
Mike Bayer [Fri, 16 May 2025 14:33:03 +0000 (10:33 -0400)] 
i think we dont need DOMAIN.adapt()

this seems to be redundant vs. what constructor copy does.

Issues are afoot w/ domain in any case see multiple issues
at [1]

[1] https://github.com/sqlalchemy/sqlalchemy/discussions/12592
Change-Id: I49879df6b78170435f021889f8f56ec43abc75c7

Change-Id: Id8fba884d47f3a494764262e23b3cc889f2cd033

7 weeks agoMerge "expand column options for composites up front at the attribute level" into...
Michael Bayer [Thu, 15 May 2025 21:40:00 +0000 (21:40 +0000)] 
Merge "expand column options for composites up front at the attribute level" into main

7 weeks agoexpand column options for composites up front at the attribute level
Mike Bayer [Thu, 15 May 2025 17:39:36 +0000 (13:39 -0400)] 
expand column options for composites up front at the attribute level

Implemented the :func:`_orm.defer`, :func:`_orm.undefer` and
:func:`_orm.load_only` loader options to work for composite attributes, a
use case that had never been supported previously.

Fixes: #12593
Change-Id: Ie7892a710f30b69c83f586f7492174a3b8198f80

7 weeks agocherry-pick changelog update for 2.0.42
Mike Bayer [Wed, 14 May 2025 17:11:06 +0000 (13:11 -0400)] 
cherry-pick changelog update for 2.0.42

7 weeks agocherry-pick changelog from 2.0.41
Mike Bayer [Wed, 14 May 2025 17:11:05 +0000 (13:11 -0400)] 
cherry-pick changelog from 2.0.41

7 weeks agouse pep639 license
Mike Bayer [Wed, 14 May 2025 12:24:44 +0000 (08:24 -0400)] 
use pep639 license

Removed the "license classifier" from setup.cfg for SQLAlchemy 2.0, which
eliminates loud deprecation warnings when building the package.  SQLAlchemy
2.1 will use a full :pep:`639` configuration in pyproject.toml while
SQLAlchemy 2.0 remains using ``setup.cfg`` for setup.

for main, also bumping setuptools to 77.0.3 as we no longer have
py3.7, 3.8 to worry about

Change-Id: If732dca7f9b57a4c6a789a68ecc77f0293be4786

7 weeks agochangelog edits
Mike Bayer [Wed, 14 May 2025 12:20:03 +0000 (08:20 -0400)] 
changelog edits

Change-Id: Ib2bb33698f58a62c945d147c39d3ac6af908b802

7 weeks agoSupport `matmul` (@) as an optional operator.
Aramís Segovia [Tue, 13 May 2025 20:18:11 +0000 (16:18 -0400)] 
Support `matmul` (@) as an optional operator.

Allow custom operator systems to use the @ Python operator (#12479).

### Description
Add a dummy implementation for the  `__matmul__` operator rasing `NotImplementedError` by default.

### 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
- [ ] 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.
- [X] 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: #12583
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12583
Pull-request-sha: 7e69d23610f39468b24c0a9a1ffdbdab20ae34fb

Change-Id: Ia0d565decd437b940efd3b97478c16d7a0377bc6

7 weeks agoremove __getattr__ from root
Mike Bayer [Tue, 13 May 2025 15:28:25 +0000 (11:28 -0400)] 
remove __getattr__ from root

Removed ``__getattr__()`` rule from ``sqlalchemy/__init__.py`` that
appeared to be trying to correct for a previous typographical error in the
imports. This rule interferes with type checking and is removed.

Fixes: #12588
Change-Id: I682b1f3c13b842d6f43ed02d28d9774b55477516

8 weeks agorewrite the docs on SQLite transaction handling
Mike Bayer [Mon, 12 May 2025 19:25:07 +0000 (15:25 -0400)] 
rewrite the docs on SQLite transaction handling

SQLite has added the new "connection.autocommit" mode and
associated fixes for pep-249 as of python 3.12.   they plan to
default to using this attribute as of python 3.16.   Get
on top of things by rewriting the whole doc section here, removing
old cruft about sqlalchemy isolation levels that was not correct
in any case, update recipes in a more succinct and unified way.

References: #12585
Change-Id: I9d1de8dcc27f1731ecd3c723718942148dcd0a1a

8 weeks agoimplement pep-649 workarounds, test suite passing for python 3.14
Mike Bayer [Thu, 6 Mar 2025 14:12:43 +0000 (09:12 -0500)] 
implement pep-649 workarounds, test suite passing for python 3.14

Changes to the test suite to accommodate Python 3.14 as of version
3.14.0b1

Originally this included a major breaking change to how python 3.14
implemented :pep:`649`, however this was resolved by [1].

As of a7, greenlet is skipped due to issues in a7 and later b1
in [2].

1. the change to rewrite all conditionals in annotation related tests
   is reverted.
2. test_memusage needed an explicit set_start_method() call so that
   it can continue to use plain fork
3. unfortunately at the moment greenlet has to be re-disabled for 3.14.
4. Changes to tox overall, remove pysqlcipher which hasn't worked
   in years, etc.
5. we need to support upcoming typing-extensions also, install the beta
6. 3.14.0a7 introduces major regressions to our runtime typing
   utilities, unfortunately, it's not clear if these can be resolved
7. for 3.14.0b1, we have to vendor get_annotations to work around [3]

[1] https://github.com/python/cpython/issues/130881
[2] https://github.com/python-greenlet/greenlet/issues/440
[3] https://github.com/python/cpython/issues/133684

py314: yes
Fixes: #12405
References: #12399
Change-Id: I8715d02fae599472dd64a2a46ccf8986239ecd99

8 weeks agoMerge "dont render URL in unparseable URL error message" into main
Michael Bayer [Thu, 8 May 2025 13:33:09 +0000 (13:33 +0000)] 
Merge "dont render URL in unparseable URL error message" into main

8 weeks agoMerge "typing: pg: type NamedType create/drops (fixes #12557)" into main
Michael Bayer [Thu, 8 May 2025 12:57:30 +0000 (12:57 +0000)] 
Merge "typing: pg: type NamedType create/drops (fixes #12557)" into main

8 weeks agodont render URL in unparseable URL error message
Mike Bayer [Thu, 8 May 2025 12:34:21 +0000 (08:34 -0400)] 
dont render URL in unparseable URL error message

The error message that is emitted when a URL cannot be parsed no longer
includes the URL itself within the error message.

Fixes: #12579
Change-Id: Icd17bd4fe0930036662b6a4fe0264cb13df04ba7

2 months agotyping: pg: type NamedType create/drops (fixes #12557)
Justine Krejcha [Tue, 6 May 2025 19:18:02 +0000 (15:18 -0400)] 
typing: pg: type NamedType create/drops (fixes #12557)

Type the `create` and `drop` functions for `NamedType`s

Also partially type the SchemaType create/drop functions more generally

One change to this is that the default parameter of `None` is removed. It doesn't work and will fail with a `AttributeError` at runtime since it immediately tries to access a property of `None` which doesn't exist.

Fixes #12557

This pull request is:

- [X] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [X] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #12558
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12558
Pull-request-sha: 75c8d81bfb68f45299a9448d45dda446532205d3

Change-Id: I173771d365f34f54ab474b9661e1cdc70cc4de84

2 months agoreorganize ORM Annotated Declarative into its own section
Mike Bayer [Tue, 6 May 2025 22:06:15 +0000 (18:06 -0400)] 
reorganize ORM Annotated Declarative into its own section

The ORM Annotated Declarative section is now very large but has been
indented under the "Declarative Table with mapped_column()" section
where it does not show up well on top level TOCs and is too deeply
nested.   Break it out into its own section following the
entire "Declarative Table" section, but also maintain a short intro
section inside of "Declarative Table" to ensure this use is still
prominent.

Change-Id: I42f4aff6ed54da249c94ddf50727f9fe3c3bd625

2 months agoMerge "Added vector datatype support in Oracle dialect" into main
Michael Bayer [Tue, 6 May 2025 13:25:29 +0000 (13:25 +0000)] 
Merge "Added vector datatype support in Oracle dialect" into main

2 months agofix failing typing test
Federico Caselli [Mon, 5 May 2025 21:03:18 +0000 (23:03 +0200)] 
fix failing typing test

fix failing test added in 4ac02007e030232f57226aafbb9313c8ff186a62

Change-Id: If0c62fac8744caa98bd04f808ef381ffb04afd7f

2 months agoFix issues in versioning.rst (#12567)
krave1986 [Mon, 5 May 2025 19:38:19 +0000 (03:38 +0800)] 
Fix issues in versioning.rst (#12567)

2 months agoRemove unused typing imports (#12568)
Shamil [Mon, 5 May 2025 18:05:21 +0000 (21:05 +0300)] 
Remove unused typing imports (#12568)

* Remove unused typing imports

* remove unused per file ignores

* Revert "remove unused per file ignores"

---------

Co-authored-by: Pablo Estevez <pablo22estevez@gmail.com>
2 months agoAdded vector datatype support in Oracle dialect
suraj [Mon, 5 May 2025 15:14:35 +0000 (11:14 -0400)] 
Added vector datatype support in Oracle dialect

Added new datatype :class:`_oracle.VECTOR` and accompanying DDL and DQL
support to fully support this type for Oracle Database. This change
includes the base :class:`_oracle.VECTOR` type that adds new type-specific
methods ``l2_distance``, ``cosine_distance``, ``inner_product`` as well as
new parameters ``oracle_vector`` for the :class:`.Index` construct,
allowing vector indexes to be configured, and ``oracle_fetch_approximate``
for the :meth:`.Select.fetch` clause.  Pull request courtesy Suraj Shaw.

Fixes: #12317
Closes: #12321
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12321
Pull-request-sha: a72a18a45c85ae7fa50a34e97ac642e16b463b54

Change-Id: I6f3af4623ce439d0820c14582cd129df293f0ba8

2 months agoMerge "fix sqlite localtimestamp function" into main
Michael Bayer [Thu, 1 May 2025 15:42:44 +0000 (15:42 +0000)] 
Merge "fix sqlite localtimestamp function" into main

2 months agoadd black dependency for format_docs_code
Mike Bayer [Thu, 1 May 2025 13:49:33 +0000 (09:49 -0400)] 
add black dependency for format_docs_code

this doesnt run if black is not installed, so use a python
env for it

Change-Id: I567d454917e7e8e4be2b7a21ffc511900f16457c

2 months agofix sqlite localtimestamp function
Mike Bayer [Thu, 1 May 2025 13:43:29 +0000 (09:43 -0400)] 
fix sqlite localtimestamp function

Fixed and added test support for a few SQLite SQL functions hardcoded into
the compiler most notably the "localtimestamp" function which rendered with
incorrect internal quoting.

Fixes: #12566
Change-Id: Id5bd8dc7841f0afab7df031ba5c0854dab845a1d

2 months agoMerge "add correct typing for row getitem" into main
Michael Bayer [Thu, 1 May 2025 13:26:10 +0000 (13:26 +0000)] 
Merge "add correct typing for row getitem" into main

2 months agoadd correct typing for row getitem
Federico Caselli [Mon, 28 Apr 2025 21:44:50 +0000 (23:44 +0200)] 
add correct typing for row getitem

The overloads were broken in 8a4c27589500bc57605bb8f28c215f5f0ae5066d

Change-Id: I3736b15e95ead28537e25169a54521e991f763da

2 months agoFix simple typo (#12555)
Ross Patterson [Tue, 29 Apr 2025 20:14:09 +0000 (13:14 -0700)] 
Fix simple typo (#12555)

2 months agoMerge "refactor (orm): remove unused variables and simplify key lookups" into main
Federico Caselli [Sun, 27 Apr 2025 19:43:33 +0000 (19:43 +0000)] 
Merge "refactor (orm): remove unused variables and simplify key lookups" into main

2 months agorefactor (orm): remove unused variables and simplify key lookups
Federico Caselli [Thu, 24 Apr 2025 22:02:32 +0000 (18:02 -0400)] 
refactor (orm): remove unused variables and simplify key lookups

Redundant variables and unnecessary conditions were removed across several modules. Improved readability and reduced code complexity without changing functionality.

Closes: #12537
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12537
Pull-request-sha: ab53f8c3487e8cfb4d4a0235c27d8a5b8557d193

Change-Id: I910d65729fdbc96933f9822c553924d37e89e201

2 months agofix reference cycles/ perf in DialectKWArgs
Mike Bayer [Sat, 26 Apr 2025 15:32:30 +0000 (11:32 -0400)] 
fix reference cycles/ perf in DialectKWArgs

Identified some unnecessary cycles and overhead in how
this is implemented.  since we want to add this to Select,
needs these improvements.

Change-Id: I4324db14aaf52ab87a8b7fa49ebf1b6624bc2dcb

2 months agoMerge "refactor(testing-and-utils): Remove unused code and fix style issues" into...
Federico Caselli [Thu, 24 Apr 2025 21:51:04 +0000 (21:51 +0000)] 
Merge "refactor(testing-and-utils): Remove unused code and fix style issues" into main

2 months agoMerge "refactor: clean up unused variables in engine module" into main
Federico Caselli [Thu, 24 Apr 2025 21:50:31 +0000 (21:50 +0000)] 
Merge "refactor: clean up unused variables in engine module" into main

2 months agoMerge "refactor (sql): simplify and optimize internal SQL handling" into main
Federico Caselli [Thu, 24 Apr 2025 21:49:58 +0000 (21:49 +0000)] 
Merge "refactor (sql): simplify and optimize internal SQL handling" into main

2 months agoMerge "refactor: simplify and clean up dialect-specific code" into main
Federico Caselli [Thu, 24 Apr 2025 20:32:06 +0000 (20:32 +0000)] 
Merge "refactor: simplify and clean up dialect-specific code" into main

2 months agoUpdate entry for sqlalchemy-hana (#12553)
Christoph Heer [Thu, 24 Apr 2025 20:00:52 +0000 (22:00 +0200)] 
Update entry for sqlalchemy-hana (#12553)

2 months agoAdd pow operator support
Federico Caselli [Fri, 4 Apr 2025 20:23:31 +0000 (22:23 +0200)] 
Add pow operator support

Added support for the pow operator (``**``), with a default SQL
implementation of the ``POW()`` function.   On Oracle Database, PostgreSQL
and MSSQL it renders as ``POWER()``.   As part of this change, the operator
routes through a new first class ``func`` member :class:`_functions.pow`,
which renders on Oracle Database, PostgreSQL and MSSQL as ``POWER()``.

Fixes: #8579
Closes: #8580
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8580
Pull-request-sha: 041b2ef474a291c6b6172e49cc6e0d548e28761a

Change-Id: I371bd44ed3e58f2d55ef705aeec7d04710c97f23

2 months agoMerge "optimize `@util.decorator`" into main
Michael Bayer [Mon, 21 Apr 2025 23:08:40 +0000 (23:08 +0000)] 
Merge "optimize `@util.decorator`" into main

2 months agorefactor (sql): simplify and optimize internal SQL handling
Shamil [Mon, 21 Apr 2025 16:36:21 +0000 (12:36 -0400)] 
refactor (sql): simplify and optimize internal SQL handling

Replaced redundant variable assignments with direct operations. Used `dict.get()` for safer dictionary lookups to streamline logic. Improves code readability and reduces unnecessary lines.

Closes: #12538
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12538
Pull-request-sha: d322d1508cfc37668099e6624816aba9c647ad51

Change-Id: Ib3dfc7086ec35117fdad65e136a17aa014b96ae5

2 months agorefactor(testing-and-utils): Remove unused code and fix style issues
Shamil [Mon, 21 Apr 2025 16:35:43 +0000 (12:35 -0400)] 
refactor(testing-and-utils): Remove unused code and fix style issues

This PR includes several small refactorings and style fixes aimed at improving code cleanliness, primarily within the test suite and tooling.

Key changes:

*   Removed assignments to unused variables in various test files (`test_dialect.py`, `test_reflection.py`, `test_select.py`).
*   Removed an unused variable in the pytest plugin (`pytestplugin.py`).
*   Removed an unused variable in the topological sort utility (`topological.py`).
*   Fixed a minor style issue (removed an extra blank line) in the `cython_imports.py` script.

Closes: #12539
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12539
Pull-request-sha: 837c1e6cb17f0ff31444d5161329c318b52e48e7

Change-Id: Ifa37fb956bc3cacd31967f08bdaa4254e16911c2

2 months agorefactor: clean up unused variables in engine module
Shamil [Thu, 17 Apr 2025 19:48:19 +0000 (15:48 -0400)] 
refactor: clean up unused variables in engine module

Removed unused variables to improve code clarity and maintainability. This change simplifies logic in `base.py`, `default.py`, and `result.py`. No functionality was altered.

Closes: #12535
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12535
Pull-request-sha: a9d849f3a4f3abe9aff49279c4cc81aa26aeaa9b

Change-Id: If78b18dbd33733c631f8b5aad7d55261fbc4817b

2 months agorefactor: simplify and clean up dialect-specific code
Shamil [Thu, 17 Apr 2025 15:23:21 +0000 (11:23 -0400)] 
refactor: simplify and clean up dialect-specific code

**Title:** Removed unused variables and redundant functions across multiple dialects. Improves code readability and reduces maintenance complexity without altering functionality.
### Description
This pull request introduces several minor refactorings across different dialect modules:
- **MSSQL:**
    - Simplified the initialization of the `fkeys` dictionary in `_get_foreign_keys` using `util.defaultdict` directly.

- **MySQL:** Removed the unused variable in `_get_table_comment`. `rp`
- **PostgreSQL (_psycopg_common):** Removed the unused variable `cursor` in `do_ping`.
- **PostgreSQL (base):** Removed the unused variable `args` in `_get_column_info`.
- **SQLite:** Removed the unused variable `new_filename` in `generate_driver_url`.

These changes focus purely on code cleanup and simplification, removing dead code and improving clarity. They do not alter the existing logic or functionality of the dialects.
### Checklist
This pull request is:
- [ ] A documentation / typographical / small typing error fix
- [x] A short code fix
    - _Note: This is a general cleanup refactor rather than a fix for a specific reported issue._

- [ ] A new feature implementation

**Have a nice day!**

Closes: #12534
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12534
Pull-request-sha: 2c7ae17b73192ba6bff6bec953b307a88ea31847

Change-Id: I1ec3b48f42aea7e45bc20f81add03051eb30bb98

2 months agodisable mysql/connector-python, again
Mike Bayer [Mon, 21 Apr 2025 13:44:40 +0000 (09:44 -0400)] 
disable mysql/connector-python, again

Just as we got this driver "working", a new regression is introduced
in version 9.3.0 which prevents basic binary string persistence [1].
I would say we need to leave this driver off for another few years
until something changes with its upstream maintenance.

[1] https://bugs.mysql.com/bug.php?id=118025

Change-Id: If876f63ebb9a6f7dfa0b316df044afa469a154f2

2 months agochore: add type hint for reconstructor (#12527)
Ryu Juheon [Thu, 17 Apr 2025 19:48:54 +0000 (04:48 +0900)] 
chore: add type hint for reconstructor (#12527)

* chore: add type hint for reconstructor

* chore: fix attr-defined

* chore: use defined typevar

* chore: ignore type error

2 months agochore: Fix typo of psycopg2 in comment (#12526)
Matt John [Tue, 15 Apr 2025 19:05:36 +0000 (20:05 +0100)] 
chore: Fix typo of psycopg2 in comment (#12526)

This is the first example in the documentation of a particular connector, which mgith result in copy+pastes, resulting in an error

2 months agoMerge "Type postgresql.aggregate_order_by()" into main
Federico Caselli [Thu, 10 Apr 2025 22:32:29 +0000 (22:32 +0000)] 
Merge "Type postgresql.aggregate_order_by()" into main

2 months agoMerge "simplify internal storage of DML ordered values" into main
Michael Bayer [Thu, 10 Apr 2025 15:07:52 +0000 (15:07 +0000)] 
Merge "simplify internal storage of DML ordered values" into main

2 months agosimplify internal storage of DML ordered values
Mike Bayer [Tue, 8 Apr 2025 01:41:29 +0000 (21:41 -0400)] 
simplify internal storage of DML ordered values

towards some refactorings I will need to do for #12496, this
factors out the "_ordered_values" list of tuples that was used to
track UPDATE VALUES in a specific order.   The rationale for this
separate collection was due to Python dictionaries not maintaining
insert order.   Now that this is standard behavior in Python 3
we can use the same `statement._values` for param-ordered and
table-column-ordered UPDATE rendering.

Change-Id: Id6024ab06e5e3ba427174e7ba3630ff83d81f603

2 months agoType postgresql.aggregate_order_by()
Denis Laxalde [Wed, 9 Apr 2025 07:04:20 +0000 (03:04 -0400)] 
Type postgresql.aggregate_order_by()

Overloading of `__init__()` is needed, probably for the same reason as it is in `ReturnTypeFromArgs`.

Related to #6810.

Closes: #12463
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12463
Pull-request-sha: 701d979e20c6ca3e32b79145c20441407007122f

Change-Id: I7e1bb4d2c48dfb3461725c7079aaa72c66f1dc03

2 months agoorm.exc.NoResultFound => exc.NoResultFound (#12509)
Inada Naoki [Tue, 8 Apr 2025 20:43:25 +0000 (05:43 +0900)] 
orm.exc.NoResultFound => exc.NoResultFound (#12509)

* s/orm.exc.NoResultFound/exc.NoResultFound/

* use _exc

2 months agooptimize `@util.decorator`
Inada Naoki [Mon, 7 Apr 2025 23:55:48 +0000 (19:55 -0400)] 
optimize `@util.decorator`

### Description

util.decorator uses code generation + eval to create signature matching wrapper.
It consumes some CPU because we can not use pyc cache.

Additionally, each wrapped function has own globals for function annotations.

By stripping function annotations from eval-ed code, compile time and memory usage are saved.

```python
from sqlalchemy.util import decorator
from sqlalchemy import *
import timeit
import tracemalloc
import sqlalchemy.orm._orm_constructors

@decorator
def with_print(fn, *args, **kwargs):
    res = fn(*args, **kwargs)
    print(f"{fn.__name__}(*{args}, **{kwargs}) => {res}")
    return res

# test
PI = 3.14

def f():
    @with_print
    def add(x: int|float, *, y: int|float=PI) -> int|float:
        return x + y
    return add

add = f()
add(1)
print(add.__annotations__)

# benchmark
print(timeit.timeit(f, number=1000)*1000, "us")

# memory
tracemalloc.start(1)
[f() for _ in range(1000)]
mem, peak = tracemalloc.get_traced_memory()
tracemalloc.stop()
print(f"{mem=}, {peak=}")
```

Result:
```
$ .venv/bin/python -VV
Python 3.14.0a6 (main, Mar 17 2025, 21:27:10) [Clang 20.1.0 ]

$ .venv/bin/python sample.py
add(*(1,), **{'y': 3.14}) => 4.140000000000001
{'x': int | float, 'y': int | float, 'return': int | float}
35.93937499681488 us
mem=9252896, peak=9300808

$ git switch -
Switched to branch 'opt-decorator'

$ .venv/bin/python sample.py
add(*(1,), **{'y': 3.14}) => 4.140000000000001
{'x': int | float, 'y': int | float, 'return': int | float}
23.32574996398762 us
mem=1439032, peak=1476423
```

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

Closes: #12502
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12502
Pull-request-sha: 34409cbbfd2dee65bf86a85a87e415c9af47dc62

Change-Id: I88b88eb6eb018608bc2881459f58564881d06641

3 months agoMerge "Support postgresql_include in UniqueConstraint and PrimaryKeyConstraint" into...
Federico Caselli [Fri, 4 Apr 2025 19:04:01 +0000 (19:04 +0000)] 
Merge "Support postgresql_include in UniqueConstraint and PrimaryKeyConstraint" into main

3 months agoMerge "improve overloads applied to generic functions" into main
Federico Caselli [Thu, 3 Apr 2025 19:22:37 +0000 (19:22 +0000)] 
Merge "improve overloads applied to generic functions" into main

3 months agodocs: Fix substr function starting index in hybrid_property example (#12482)
krave1986 [Thu, 3 Apr 2025 18:55:36 +0000 (02:55 +0800)] 
docs: Fix substr function starting index in hybrid_property example (#12482)

3 months agoFix typo (#12495)
Adriaan Joubert [Thu, 3 Apr 2025 17:56:29 +0000 (20:56 +0300)] 
Fix typo (#12495)

3 months agoMerge "ensure ON UPDATE test is case insensitive" into main
Michael Bayer [Wed, 2 Apr 2025 16:32:35 +0000 (16:32 +0000)] 
Merge "ensure ON UPDATE test is case insensitive" into main

3 months agoensure ON UPDATE test is case insensitive
Alexander Ruehe [Tue, 1 Apr 2025 21:52:12 +0000 (17:52 -0400)] 
ensure ON UPDATE test is case insensitive

Fixed regression caused by the DEFAULT rendering changes in 2.0.40
:ticket:`12425` where using lowercase `on update` in a MySQL server default
would incorrectly apply parenthesis, leading to errors when MySQL
interpreted the rendered DDL.  Pull request courtesy Alexander Ruehe.

Fixes: #12488
Closes: #12489
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12489
Pull-request-sha: b9008f747d21bc06a4006c99a47fc6aa99407636

Change-Id: If5281c52415e4ddb6c2f8aee191d2335f6673b35

3 months agominor cleanup of postgresql index reflection query
Federico Caselli [Tue, 1 Apr 2025 21:49:36 +0000 (23:49 +0200)] 
minor cleanup of postgresql index reflection query

Change-Id: I669ea8e99c6b69cb70263b0cacd80d3ed0fab39c

3 months agoSupport postgresql_include in UniqueConstraint and PrimaryKeyConstraint
Denis Laxalde [Tue, 1 Apr 2025 17:30:48 +0000 (13:30 -0400)] 
Support postgresql_include in UniqueConstraint and PrimaryKeyConstraint

This is supported both for schema definition and reflection.

Fixes #10665.

Closes: #12485
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12485
Pull-request-sha: 1aabea7b55ece9fc0c6e069b777d4404ac01f964

Change-Id: I81d23966f84390dd1b03f0d13284ce6d883ee24e

3 months agoMerge "Add type annotations to postgresql.pg_catalog" into main
Federico Caselli [Tue, 1 Apr 2025 19:10:01 +0000 (19:10 +0000)] 
Merge "Add type annotations to postgresql.pg_catalog" into main

3 months agoMerge "Removed executable coercion" into main
Michael Bayer [Mon, 31 Mar 2025 12:34:16 +0000 (12:34 +0000)] 
Merge "Removed executable coercion" into main

3 months agocherry-pick changelog update for 2.0.41
Mike Bayer [Thu, 27 Mar 2025 17:52:56 +0000 (13:52 -0400)] 
cherry-pick changelog update for 2.0.41

3 months agocherry-pick changelog from 2.0.40
Mike Bayer [Thu, 27 Mar 2025 17:52:56 +0000 (13:52 -0400)] 
cherry-pick changelog from 2.0.40

3 months agochangelog update
Mike Bayer [Thu, 27 Mar 2025 16:47:43 +0000 (12:47 -0400)] 
changelog update

Change-Id: I03202183f4045030bc2940c43d637edc3524b5d4

3 months agoMerge "Type array_agg()" into main
Michael Bayer [Thu, 27 Mar 2025 16:34:35 +0000 (16:34 +0000)] 
Merge "Type array_agg()" into main

3 months agoMerge "implement AsyncSessionTransaction._regenerate_proxy_for_target" into main
Michael Bayer [Thu, 27 Mar 2025 16:29:58 +0000 (16:29 +0000)] 
Merge "implement AsyncSessionTransaction._regenerate_proxy_for_target" into main

3 months agoimplement AsyncSessionTransaction._regenerate_proxy_for_target
Mike Bayer [Wed, 26 Mar 2025 17:55:46 +0000 (13:55 -0400)] 
implement AsyncSessionTransaction._regenerate_proxy_for_target

Fixed issue where :meth:`.AsyncSession.get_transaction` and
:meth:`.AsyncSession.get_nested_transaction` would fail with
``NotImplementedError`` if the "proxy transaction" used by
:class:`.AsyncSession` were garbage collected and needed regeneration.

Fixes: #12471
Change-Id: Ia8055524618df706d7958786a500cdd25d9d8eaf

3 months agoImplement GROUPS frame spec for window functions
Kaan [Wed, 19 Mar 2025 15:58:30 +0000 (11:58 -0400)] 
Implement GROUPS frame spec for window functions

Implemented support for the GROUPS frame specification in window functions
by adding :paramref:`_sql.over.groups` option to :func:`_sql.over`
and :meth:`.FunctionElement.over`. Pull request courtesy Kaan Dikmen.

Fixes: #12450
Closes: #12445
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12445
Pull-request-sha: c0808e135f15c7fef3a3abcf28465673f38eb428

Change-Id: I9ff504a9c9650485830c4a0eaf44162898a3a2ad

3 months agoMerge "compatibility with typing_extensions 4.13 and type statement" into main
Michael Bayer [Thu, 27 Mar 2025 13:33:30 +0000 (13:33 +0000)] 
Merge "compatibility with typing_extensions 4.13 and type statement" into main

3 months agocompatibility with typing_extensions 4.13 and type statement
Daraan [Wed, 26 Mar 2025 18:27:46 +0000 (14:27 -0400)] 
compatibility with typing_extensions 4.13 and type statement

Fixed regression caused by ``typing_extension==4.13.0`` that introduced
a different implementation for ``TypeAliasType`` while SQLAlchemy assumed
that it would be equivalent to the ``typing`` version.

Added test regarding generic TypeAliasType

Fixes: #12473
Closes: #12472
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12472
Pull-request-sha: 8861a5acfb8e81663413ff144b41abf64779b6fd

Change-Id: I053019a222546a625ed6d588314ae9f5b34c2f8a

3 months agodocument sqlite truncate_microseconds in DATETIME and TIME
Federico Caselli [Wed, 26 Mar 2025 20:43:10 +0000 (21:43 +0100)] 
document sqlite truncate_microseconds in DATETIME and TIME

Change-Id: I93412d951b466343f2cf9b6d513ad46d17f5d8ee

3 months agoMerge "Increase minimum required greenlet version" into main
Federico Caselli [Wed, 26 Mar 2025 12:09:01 +0000 (12:09 +0000)] 
Merge "Increase minimum required greenlet version" into main

3 months agoimprove overloads applied to generic functions
Federico Caselli [Mon, 24 Mar 2025 20:50:45 +0000 (21:50 +0100)] 
improve overloads applied to generic functions

try again to remove the overloads to the generic functionn
generator (like coalesce, array_agg, etc).
As of mypy 1.15 it still does now work, but a simpler version
is added in this change

Change-Id: I8b97ae00298ec6f6bf8580090e5defff71e1ceb0

3 months agoIncrease minimum required greenlet version
Chris Withers [Tue, 25 Mar 2025 19:05:23 +0000 (15:05 -0400)] 
Increase minimum required greenlet version

Add a lower bound constraint on the greenlet version to 1.

Closes: #12459
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12459
Pull-request-sha: 4bd856b9c164df984f05c094c977686470ed4244

Change-Id: I200861f1706bf261c2e586b96e8cc35dceb7670b

3 months agoAdd missing imports to example (#12453)
Stefanie Molin [Tue, 25 Mar 2025 19:05:44 +0000 (15:05 -0400)] 
Add missing imports to example (#12453)

3 months agoAdd type annotations to postgresql.pg_catalog
Denis Laxalde [Tue, 25 Mar 2025 08:51:30 +0000 (04:51 -0400)] 
Add type annotations to postgresql.pg_catalog

Related to #6810.

Closes: #12462
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12462
Pull-request-sha: 5a131cc9a94a2c9efa0e888fe504ebc03d84c7f0

Change-Id: Ie4494d61f815edefef6a896499db4292fd94a22a