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

10 months agoMerge "Add new str` subclass for postgresql bitstring" into main
Michael Bayer [Wed, 2 Jul 2025 17:01:47 +0000 (17:01 +0000)] 
Merge "Add new str` subclass for postgresql bitstring" into main

10 months agonote that SQL parenthesis are based on precedence
Mike Bayer [Wed, 2 Jul 2025 13:18:28 +0000 (09:18 -0400)] 
note that SQL parenthesis are based on precedence

References: #12708
Change-Id: I2401e92c936eb01a64ad6896a86faec1c205bc08

10 months agoAdd new str` subclass for postgresql bitstring
Federico Caselli [Fri, 20 Jun 2025 20:28:45 +0000 (22:28 +0200)] 
Add new str` subclass for postgresql bitstring

Adds a new ``str`` subclass :class:`dialects.postgresql.BitString`
representing PostgreSQL bitstrings in python, that includes
functionality for converting to and from ``int`` and ``bytes``, in
addition to implementing utility methods and operators for dealing
with bits.

This new class is returned automatically by the :class:`postgresql.BIT`
type.

Fixes: #10556
Closes: #12594
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12594
Pull-request-sha: da47f40739ff9fc6e75da44bd1663aadf80e93ca

Change-Id: I64685660527c23666f7351b2c393fa86dfb643ea

11 months agoMerge "Update association examples to Declarative API" into main
Michael Bayer [Mon, 30 Jun 2025 14:35:10 +0000 (14:35 +0000)] 
Merge "Update association examples to Declarative API" into main

11 months agoMerge "remove support for list of tuples in the normal execute" into main
Michael Bayer [Fri, 27 Jun 2025 15:36:31 +0000 (15:36 +0000)] 
Merge "remove support for list of tuples in the normal execute" into main

11 months agofix typos in comment
Federico Caselli [Thu, 26 Jun 2025 20:05:10 +0000 (22:05 +0200)] 
fix typos in comment

Change-Id: I84edcb6100ee9c072c68970cd476f02d48f7f7ac

11 months agoremove support for list of tuples in the normal execute
Federico Caselli [Thu, 5 Jun 2025 18:09:32 +0000 (20:09 +0200)] 
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

11 months agoUpdate association examples to Declarative API
Mike Fiedler [Thu, 26 Jun 2025 19:04:03 +0000 (15:04 -0400)] 
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: dad6239370f23d52b4c0a1b21eba5752e216207e

Change-Id: Id5c2d65137c5e9d7e87778acd51b965c2bcf315a

11 months agoMerge "Simplify postgresql index reflection query" into main
Federico Caselli [Thu, 26 Jun 2025 15:48:23 +0000 (15:48 +0000)] 
Merge "Simplify postgresql index reflection query" into main

11 months agoMerge "add example to update from that uses values" into main
Michael Bayer [Tue, 24 Jun 2025 22:28:21 +0000 (22:28 +0000)] 
Merge "add example to update from that uses values" into main

11 months agouse zzzeeksphinx 1.6.1 and we arent' really using this doc mod
Mike Bayer [Tue, 24 Jun 2025 22:26:44 +0000 (18:26 -0400)] 
use zzzeeksphinx 1.6.1 and we arent' really using this doc mod

Change-Id: Ib53111444598331290bde1788f5f2617562d250c

11 months agoadd example to update from that uses values
Federico Caselli [Tue, 10 Jun 2025 21:42:35 +0000 (23:42 +0200)] 
add example to update from that uses values

Change-Id: Ic02a722be9a30851a87e0da4759c728e86fb22c8
References: #11768

11 months agoMerge "try flake8-import-order 0.19.2" into main
Michael Bayer [Tue, 24 Jun 2025 20:52:10 +0000 (20:52 +0000)] 
Merge "try flake8-import-order 0.19.2" into main

11 months agoMerge "hardening against inappropriate multi-table updates" into main
Michael Bayer [Tue, 24 Jun 2025 18:41:17 +0000 (18:41 +0000)] 
Merge "hardening against inappropriate multi-table updates" into main

11 months agotry flake8-import-order 0.19.2
Mike Bayer [Tue, 24 Jun 2025 17:57:17 +0000 (13:57 -0400)] 
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

11 months agohardening against inappropriate multi-table updates
Mike Bayer [Mon, 23 Jun 2025 13:21:59 +0000 (09:21 -0400)] 
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

11 months agoMerge "Extend #12168 to relationship collections" into main
Michael Bayer [Mon, 23 Jun 2025 19:19:06 +0000 (19:19 +0000)] 
Merge "Extend #12168 to relationship collections" into main

11 months agoMerge "rework wraps_column_expression logic to be purely compile time checking" into...
Michael Bayer [Sat, 21 Jun 2025 23:44:18 +0000 (23:44 +0000)] 
Merge "rework wraps_column_expression logic to be purely compile time checking" into main

11 months agoUpdate `table_per_related` example for Declarative API
Mike Fiedler [Fri, 20 Jun 2025 21:49:26 +0000 (17:49 -0400)] 
Update `table_per_related` example for Declarative API

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

### Description
When reading more of the Generic Associations, I found that the examples state "Annotated example", and wondered what that meant, since in other parts of the docs that means they are using the new 2.0 style.

I tried to update this example to be more in line with the new style, including a little f-string update.

I completely understand this is unlikely to be merged as-is - but wanted to understand more about the right way to use modern styles to properly code well-hinted, more "exotic" implementations.

Outstanding questions:
- Should examples pass pass `mypy --strict` ? It doesn't right now.
- Are there better ways to apply `Mapped` within the `type(...)` definition, so we could skip importing `Integer`?

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

(Do non-running examples count as code fixes/features?)

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

**Have a nice day!**

Closes: #10450
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10450
Pull-request-sha: a6a54d69487429c8b3a7758cf22913e6a2156316

Change-Id: Ie7c7526daed5bf907d41f666459759b9a986b8c2

11 months agotype `set_committed_value`.
Federico Caselli [Fri, 20 Jun 2025 21:16:22 +0000 (23:16 +0200)] 
type `set_committed_value`.

Fixes: #12669
Change-Id: I9c73184d4c4880d0cd72eaafe125b3cf48bedf02

11 months agoExtend #12168 to relationship collections
Mike Bayer [Fri, 20 Jun 2025 13:20:27 +0000 (09:20 -0400)] 
Extend #12168 to relationship collections

As seen in [1] we need to extend the "no default set" case a bit
more to help get dataclasses to act more like traditional mapped
classes.

[1] https://github.com/sqlalchemy/sqlalchemy/issues/9410#issuecomment-2989758246

Fixes: #12168
Change-Id: Icb11faf2203460ab5bca4f2eb5b08b7563cff758

11 months agoreally pin flake8-import-order to <0.19
Mike Bayer [Fri, 20 Jun 2025 17:04:54 +0000 (13:04 -0400)] 
really pin flake8-import-order to <0.19

In 8a287bf5c5635daf99217e I told @caselit to just omit 0.19.0,
as I wa sure 0.19.1 would fix the issue.  Unfortunately in [1]
we see that this release continues to have problems, which seems
to be related not to the importlib.metadata fix but to an unrelated
improvement for TYPE_CHECKING blocks.

So we really have to wait for them to get a working release before
we can update.

Change-Id: Ia82a98e836bed9e826906bd07827a9e00998bf7c

11 months agoMerge "remove util.portable_instancemethod" into main
Michael Bayer [Thu, 19 Jun 2025 14:39:23 +0000 (14:39 +0000)] 
Merge "remove util.portable_instancemethod" into main

11 months agorework wraps_column_expression logic to be purely compile time checking
Mike Bayer [Mon, 16 Jun 2025 23:53:30 +0000 (19:53 -0400)] 
rework wraps_column_expression logic to be purely compile time checking

Fixed issue where :func:`.select` of a free-standing, unnamed scalar expression that
has a unary operator applied, such as negation, would not apply result
processors to the selected column even though the correct type remains in
place for the unary expression.

This change opened up a typing rabbithole where we were led to also
improve and harden the typing for the Exists element, in particular
in that the Exists now always refers to a ScalarSelect object, and
no longer a SelectStatementGrouping within the _regroup() cases; there
did not seem to be any reason for this inconsistency.

Fixes: #12681
Change-Id: If9131807941030c627ab31ede4ccbd86e44e707f

11 months agoMerge remote-tracking branch 'origin/pr/12657'
Federico Caselli [Tue, 17 Jun 2025 19:45:05 +0000 (21:45 +0200)] 
Merge remote-tracking branch 'origin/pr/12657'

Change-Id: I601716ff468c801d4c49526440f746e20d2719f4

11 months agopin flake8-import-order!=0.19.0 and updates for mypy 1.16.1
Federico Caselli [Mon, 16 Jun 2025 19:20:58 +0000 (21:20 +0200)] 
pin flake8-import-order!=0.19.0 and updates for mypy 1.16.1

Change-Id: Ic5caffe7fb7082869753947c943c8c49f0ecfc56

11 months agoupdate pickle tests
Mike Bayer [Wed, 11 Jun 2025 18:55:14 +0000 (14:55 -0400)] 
update pickle tests

Since I want to get rid of util.portable_instancemethod, first
make sure we are testing pickle extensively including going through
all protocols for all metadata-oriented tests.

Change-Id: I0064bc16033939780e50c7a8a4ede60ef5835b38

11 months agoremove util.portable_instancemethod
Mike Bayer [Tue, 10 Jun 2025 18:51:57 +0000 (14:51 -0400)] 
remove util.portable_instancemethod

python seems to be able to pickle instance methods since
version 3.4.    Doing a bisect shows it's
https://github.com/python/cpython/commit/c9dc4a2a8a6dcfe1674685bea4a4af935c0e37ca
where pickle protocol 4 was added, however we can see that protocols 0
through 4 also support pickling of methods.   None of this documented.

Change-Id: I9e73a35e9ab2ffd2050daf819265fc6b4ddb9019

11 months agoMerge "use integer division on maxlen" into main
Michael Bayer [Tue, 10 Jun 2025 22:26:43 +0000 (22:26 +0000)] 
Merge "use integer division on maxlen" into main

11 months agofix wrong reference link in changelog
Federico Caselli [Tue, 10 Jun 2025 22:11:10 +0000 (00:11 +0200)] 
fix wrong reference link in changelog

Change-Id: I55cf7c6f128cd618cb261b38929bf962586b59e8

11 months agouse integer division on maxlen
Mike Bayer [Tue, 10 Jun 2025 21:33:14 +0000 (17:33 -0400)] 
use integer division on maxlen

this was coming out as a float and breaking alembic column
compare

Change-Id: I50160cfdb2f2933331d3c316c9985f24fb914242

11 months agofix typo in docs
Federico Caselli [Tue, 10 Jun 2025 20:18:38 +0000 (22:18 +0200)] 
fix typo in docs

Change-Id: I675636e7322ba95bb8f5f8107d5a8f3dbbc689ca

11 months agoMerge "use sys.columns to allow accurate joining to other SYS tables" into main
Michael Bayer [Tue, 10 Jun 2025 14:55:49 +0000 (14:55 +0000)] 
Merge "use sys.columns to allow accurate joining to other SYS tables" into main

11 months agoMerge "update tox mypy" into main
Michael Bayer [Tue, 10 Jun 2025 14:37:09 +0000 (14:37 +0000)] 
Merge "update tox mypy" into main

11 months agodocument column_expression applies only to outermost statement
Mike Bayer [Tue, 10 Jun 2025 14:07:53 +0000 (10:07 -0400)] 
document column_expression applies only to outermost statement

References: https://github.com/sqlalchemy/sqlalchemy/discussions/12660
Change-Id: Id7cf98bd4560804b2f778cde41642f02f7edaf95

11 months agoupdate tox mypy
Pablo Estevez [Mon, 9 Jun 2025 12:49:13 +0000 (08:49 -0400)] 
update tox mypy

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

After this commit https://github.com/sqlalchemy/sqlalchemy/commit/68cd3e8ec7098d4bb4b2102ad247f84cd89dfd8c
tox will fail with mypy below 1.16, at least locally.

### Description
<!-- Describe your changes in detail -->

### 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.
- [ ] 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: #12655
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12655
Pull-request-sha: 15acf6b06570048d81aae89ef1d9f9a8ff83d88c

Change-Id: I7eb29a939a701ffd3a89a03d9705ab4954e66ffb

11 months agoguard against schema_translate_map adding/removing None vs. caching
Mike Bayer [Tue, 10 Jun 2025 13:21:01 +0000 (09:21 -0400)] 
guard against schema_translate_map adding/removing None vs. caching

Change-Id: Iad29848b5fe15e314ad791b7fc0aac58700b0c68

11 months agouse sys.columns to allow accurate joining to other SYS tables
Mike Bayer [Sun, 8 Jun 2025 17:01:45 +0000 (13:01 -0400)] 
use sys.columns to allow accurate joining to other SYS tables

Reworked SQL Server column reflection to be based on the ``sys.columns``
table rather than ``information_schema.columns`` view.  By correctly using
the SQL Server ``object_id()`` function as a lead and joining to related
tables on object_id rather than names, this repairs a variety of issues in
SQL Server reflection, including:

* Issue where reflected column comments would not correctly line up
with the columns themselves in the case that the table had been ALTERed
* Correctly targets tables with awkward names such as names with brackets,
when reflecting not just the basic table / columns but also extended
information including IDENTITY, computed columns, comments which
did not work previously
* Correctly targets IDENTITY, computed status from temporary tables
which did not work previously

Fixes: #12654
Change-Id: I3bf3088c3eec8d7d3d2abc9da35f9628ef78d537

11 months agoUpdate dialect opengauss url 12657/head
victor [Mon, 9 Jun 2025 12:15:12 +0000 (20:15 +0800)] 
Update dialect opengauss url

11 months agoFix missing data type in Article.writer_id mapping example (#12649)
krave1986 [Sat, 7 Jun 2025 20:03:10 +0000 (04:03 +0800)] 
Fix missing data type in Article.writer_id mapping example (#12649)

11 months agoupdate docs for "copy column" warning
Mike Bayer [Sat, 7 Jun 2025 13:01:14 +0000 (09:01 -0400)] 
update docs for "copy column" warning

these docs failed to mention we're talking about ORM flush

References: #12650
Change-Id: I3a1655ba99e98021327c90d5cd0c0f8258f4ddc6

11 months agohardcode now(), current_timstamp() into the MySQL regex
Mike Bayer [Thu, 5 Jun 2025 12:58:49 +0000 (08:58 -0400)] 
hardcode now(), current_timstamp() into the MySQL regex

Fixed yet another regression caused by by the DEFAULT rendering changes in
2.0.40 :ticket:`12425`, similar to :ticket:`12488`, this time where using a
CURRENT_TIMESTAMP function with a fractional seconds portion inside a
textual default value would also fail to be recognized as a
non-parenthesized server default.

There's no way to do this other than start hardcoding a list
of MySQL functions that demand that parenthesis are not added around
them, I can think of no other heuristic that will work here.
Suggestions welcome

Fixes: #12648
Change-Id: I75d274b56306089929b369ecfb23604e9d6fa9dd

11 months agoMerge "Remove type key in mysql index reflection dicts" into main
Michael Bayer [Wed, 4 Jun 2025 00:06:08 +0000 (00:06 +0000)] 
Merge "Remove type key in mysql index reflection dicts" into main

11 months agogive up on running py 3.14 in github actions
Mike Bayer [Tue, 3 Jun 2025 21:55:40 +0000 (17:55 -0400)] 
give up on running py 3.14 in github actions

not worth it

this is a good learning case for why we use jenkins

Change-Id: If70b0029545c70c0b5a9e1c203c853164caef874

11 months agouse exact py3.14 version
Mike Bayer [Tue, 3 Jun 2025 21:15:54 +0000 (17:15 -0400)] 
use exact py3.14 version

gh actions is not complaining that the exact string "3.13", "3.12"
etc are not in versions-manifest.json, but for 3.14 it's complaining.
not happy to hardcode this but just to get it running

Change-Id: Icf12e64b5a76a7068e196454f1fadfecb60bc4d4

11 months 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

11 months agoSimplify postgresql index reflection query
Federico Caselli [Wed, 28 May 2025 20:03:51 +0000 (22:03 +0200)] 
Simplify postgresql index reflection query

Match on python side the values of `pg_am` and `pg_opclass`
to avoid joining them in the main query.
Since both queries have a limited size and are generally
stable their value can be cached using the inspector
cache.

Change-Id: I7074e88dc9ffb8f9c53c3cc12f1a7b72eec7fe8c

11 months 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

11 months 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

11 months 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

11 months 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

11 months 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

11 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months agoRemove type key in mysql index reflection dicts
Federico Caselli [Fri, 10 Jan 2025 22:26:50 +0000 (23:26 +0100)] 
Remove type key in mysql index reflection dicts

Updated the reflection logic for indexes in the MariaDB and MySQL
dialect to avoid setting the undocumented ``type`` key in the
:class:`_engine.ReflectedIndex` dicts returned by
:class:`_engine.Inspector.get_indexes` method.

Fixes: #12240
Change-Id: Id188d8add441fe2070f36950569401c63ee35ffa

12 months 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

12 months 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)

12 months 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)

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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)

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

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

Change-Id: Ib2bb33698f58a62c945d147c39d3ac6af908b802

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 months 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

12 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

12 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

12 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

12 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

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

12 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>
12 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

13 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

13 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

13 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

13 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

13 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

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