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

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

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

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

Change-Id: I327961111c4f785a1a21dfabbf620f9f8f8f5d90

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

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

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

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

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

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

Change-Id: I40994de5197271060e97a0bd7bccafc7c08918d8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

10 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

10 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

10 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

10 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

10 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

10 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

10 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

10 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

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

10 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

10 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

11 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`.

11 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

11 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

11 months agosupport insert of table columns in specific positions
Mike Bayer [Thu, 19 Jun 2025 16:39:17 +0000 (12:39 -0400)] 
support insert of table columns in specific positions

Added method :meth:`.TableClause.insert_column` to complement
:meth:`.TableClause.append_column`, which inserts the given column at a
specific index.   This can be helpful for prepending primary key columns to
tables, etc.

Fixes: #7910
Change-Id: Ife1eb8ad90aa61d38c457a86312cfe5d0d471106

11 months agochore: Fix typo in autoflush warning (#12713)
Sillocan [Wed, 2 Jul 2025 21:20:47 +0000 (14:20 -0700)] 
chore: Fix typo in autoflush warning (#12713)

11 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

11 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

11 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 agotype aiosqlite
Pablo Estevez [Thu, 26 Jun 2025 19:21:55 +0000 (15:21 -0400)] 
type aiosqlite

Closes: #12656
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12656
Pull-request-sha: 396e9cfaaccbc56537b967e62decbbb3eb0e036a

Change-Id: I598ee6022616f265824291544750e571eaba413c

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)

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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

12 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