]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 months agoMerge "remove non_primary parameter" into main
Michael Bayer [Mon, 17 Mar 2025 21:18:49 +0000 (21:18 +0000)] 
Merge "remove non_primary parameter" into main

4 months agofix rst target for Insert
Federico Caselli [Mon, 17 Mar 2025 20:33:31 +0000 (21:33 +0100)] 
fix rst target for Insert

Change-Id: Iee0b8e90223722c40b25c309c47fd6175680ca0e

4 months agoadd postgresql distinct_on (patch 4)
Mike Bayer [Tue, 25 Feb 2025 15:11:29 +0000 (10:11 -0500)] 
add postgresql distinct_on  (patch 4)

Added syntax extension :func:`_postgresql.distinct_on` to build ``DISTINCT
ON`` clauses. The old api, that passed columns to
:meth:`_sql.Select.distinct`, is now deprecated.

Fixes: #12342
Change-Id: Ia6a7e647a11e57b6ac2f50848778c20dc55eaf54

4 months agoexpand paren rules for default rendering, sqlite/mysql
Mike Bayer [Wed, 12 Mar 2025 20:25:48 +0000 (16:25 -0400)] 
expand paren rules for default rendering, sqlite/mysql

Expanded the rules for when to apply parenthesis to a server default in DDL
to suit the general case of a default string that contains non-word
characters such as spaces or operators and is not a string literal.

Fixed issue in MySQL server default reflection where a default that has
spaces would not be correctly reflected.  Additionally, expanded the rules
for when to apply parenthesis to a server default in DDL to suit the
general case of a default string that contains non-word characters such as
spaces or operators and is not a string literal.

Fixes: #12425
Change-Id: Ie40703dcd5fdc135025d676c01baba57ff3b71ad

4 months agoSupport column list for foreign key ON DELETE SET actions on PostgreSQL
Denis Laxalde [Thu, 13 Mar 2025 12:43:53 +0000 (08:43 -0400)] 
Support column list for foreign key ON DELETE SET actions on PostgreSQL

Added support for specifying a list of columns for ``SET NULL`` and ``SET
DEFAULT`` actions of ``ON DELETE`` clause of foreign key definition on
PostgreSQL.  Pull request courtesy Denis Laxalde.

Fixes: #11595
Closes: #12421
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12421
Pull-request-sha: d0394db7066ba8a8eaf3d3972d779f3e170e9406

Change-Id: I036a559ae4a8efafe9ba64d776a840bd785a7397

4 months agoMerge "miscellaneous to type dialects" into main
Michael Bayer [Mon, 17 Mar 2025 17:35:20 +0000 (17:35 +0000)] 
Merge "miscellaneous to type dialects" into main

4 months agoMerge "Removes old version added and change notes" into main
Michael Bayer [Mon, 17 Mar 2025 17:31:19 +0000 (17:31 +0000)] 
Merge "Removes old version added and change notes" into main

4 months agoMerge "Add type annotations to `postgresql.array`" into main
Michael Bayer [Mon, 17 Mar 2025 17:29:31 +0000 (17:29 +0000)] 
Merge "Add type annotations to `postgresql.array`" into main

4 months agoremove non_primary parameter
Mike Bayer [Mon, 17 Mar 2025 12:53:00 +0000 (08:53 -0400)] 
remove non_primary parameter

The "non primary" mapper feature, long deprecated in SQLAlchemy since
version 1.3, has been removed.   The sole use case for "non primary"
mappers was that of using :func:`_orm.relationship` to link to a mapped
class against an alternative selectable; this use case is now suited by the
:doc:`relationship_aliased_class` feature.

Fixes: #12437
Change-Id: I6987da06beb1d88d6f6e9696ce93e7fc340fc0ef

4 months agoRemoves old version added and change notes
Federico Caselli [Sun, 16 Mar 2025 20:51:00 +0000 (21:51 +0100)] 
Removes old version added and change notes

Removes documentation notes for changes and addition prior to 1.3
included.

Change-Id: Ibabb5222ccafa0c27c8ec40e31b149707d9c8aa3

4 months agoAdd type annotations to `postgresql.array`
Denis Laxalde [Fri, 14 Mar 2025 21:01:50 +0000 (17:01 -0400)] 
Add type annotations to `postgresql.array`

Improved static typing for `postgresql.array()` by making the type parameter (the type of array's elements) inferred from the `clauses` and `type_` arguments while also ensuring they are consistent.

Also completed type annotations of `postgresql.ARRAY` following commit 0bf7e02afbec557eb3a5607db407f27deb7aac77 and added type annotations for functions `postgresql.Any()` and `postgresql.All()`.

Finally, fixed shadowing `typing.Any` by the `Any()` function through aliasing as `typing_Any`.

Related to #6810

Closes: #12384
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12384
Pull-request-sha: 78eea29f1de850afda036502974521969629de7e

Change-Id: I5d35d15ec8ba4d58eeb9bf00abb710e2e585731f

4 months agomiscellaneous to type dialects
Pablo Estevez [Sat, 8 Feb 2025 15:46:24 +0000 (10:46 -0500)] 
miscellaneous to type dialects

Type of certain methods that are called by dialect, so typing dialects is easier.

Related to https://github.com/sqlalchemy/sqlalchemy/pull/12164

breaking changes:

- Change modifiers from TextClause to InmutableDict, from Mapping, as is in the other classes

Closes: #12231
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12231
Pull-request-sha: 514fe4751c7b1ceefffed2a4ef9c8df339bd9c25

Change-Id: I29314045b2c7eb5428f8d6fec8911c4b6d5ae73e

4 months agoanonymize CRUD params if visiting_cte is present
Mike Bayer [Fri, 14 Mar 2025 14:33:22 +0000 (10:33 -0400)] 
anonymize CRUD params if visiting_cte is present

Fixed issue in :class:`.CTE` constructs involving multiple DDL
:class:`.Insert` statements with multiple VALUES parameter sets where the
bound parameter names generated for these parameter sets would conflict,
generating a compile time error.

Fixes: #12363
Change-Id: If8344ff725d4e0ec58d3ff61f38a0edcfc5bdebd

4 months agoMerge "re-support mysql-connector python" into main
Michael Bayer [Fri, 14 Mar 2025 12:58:23 +0000 (12:58 +0000)] 
Merge "re-support mysql-connector python" into main

4 months agoMerge "callcount updates" into main
Michael Bayer [Thu, 13 Mar 2025 15:28:25 +0000 (15:28 +0000)] 
Merge "callcount updates" into main

4 months agoMerge "Complement type annotations for ARRAY" into main
Michael Bayer [Thu, 13 Mar 2025 15:27:25 +0000 (15:27 +0000)] 
Merge "Complement type annotations for ARRAY" into main

4 months agocallcount updates
Mike Bayer [Thu, 13 Mar 2025 14:26:50 +0000 (10:26 -0400)] 
callcount updates

not clear why this isn't happening on all py312s but this adjust
profiles for some memory changes that have occurred as of
88b77c8b19523e15d3595b0a58 - just the merge change, not the actual
code change for whatever reason.  very strange

Change-Id: I67849259ea29e5bfb1527036e0d9f63071ec4d4d

4 months agocherry-pick changelog update for 2.0.40
Mike Bayer [Tue, 11 Mar 2025 18:27:27 +0000 (14:27 -0400)] 
cherry-pick changelog update for 2.0.40

4 months agocherry-pick changelog from 2.0.39
Mike Bayer [Tue, 11 Mar 2025 18:27:27 +0000 (14:27 -0400)] 
cherry-pick changelog from 2.0.39

4 months agoMerge "Ensure PostgreSQL network address types are not cast as VARCHAR" into main
Michael Bayer [Tue, 11 Mar 2025 18:07:05 +0000 (18:07 +0000)] 
Merge "Ensure PostgreSQL network address types are not cast as VARCHAR" into main

4 months agoEnsure PostgreSQL network address types are not cast as VARCHAR
Denis Laxalde [Tue, 11 Mar 2025 13:27:13 +0000 (09:27 -0400)] 
Ensure PostgreSQL network address types are not cast as VARCHAR

Fixed issue in PostgreSQL network types :class:`_postgresql.INET`,
:class:`_postgresql.CIDR`, :class:`_postgresql.MACADDR`,
:class:`_postgresql.MACADDR8` where sending string values to compare to
these types would render an explicit CAST to VARCHAR, causing some SQL /
driver combinations to fail.  Pull request courtesy Denis Laxalde.

Fixes: #12060
Closes: #12412
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12412
Pull-request-sha: 029fda7f2d182af71ebc48aef191aa9114927f28

Change-Id: Id4a502ebc119775567cacddbabef2ce9715c1a9f

4 months agoconsolidate kwargs for "FOR UPDATE OF"
Mike Bayer [Tue, 11 Mar 2025 12:33:30 +0000 (08:33 -0400)] 
consolidate kwargs for "FOR UPDATE OF"

Fixed compiler issue in the PostgreSQL dialect where incorrect keywords
would be passed when using "FOR UPDATE OF" inside of a subquery.

Fixes: #12417
Change-Id: I6255d165e8e719e1786e78aa60ee8e6a95af1dcb

4 months agore-support mysql-connector python
Mike Bayer [Sun, 23 Feb 2025 16:20:18 +0000 (11:20 -0500)] 
re-support mysql-connector python

Support has been re-added for the MySQL-Connector/Python DBAPI using the
``mysql+mysqlconnector://`` URL scheme.   The DBAPI now works against
modern MySQL versions as well as MariaDB versions (in the latter case it's
required to pass charset/collation explicitly).   Note however that
server side cursor support is disabled due to unresolved issues with this
driver.

References: #12332
Change-Id: I81279478196e830d3c0d5f24ecb3fe2dc18d4ca6

4 months agoMerge "restate all upsert in terms of statement extensions (patch 3)" into main
Michael Bayer [Fri, 7 Mar 2025 15:09:00 +0000 (15:09 +0000)] 
Merge "restate all upsert in terms of statement extensions (patch 3)" into main

4 months agoMerge "Improve identity column reflection" into main
Michael Bayer [Fri, 7 Mar 2025 14:20:45 +0000 (14:20 +0000)] 
Merge "Improve identity column reflection" into main

4 months agoImprove identity column reflection
Federico Caselli [Mon, 3 Mar 2025 22:35:48 +0000 (23:35 +0100)] 
Improve identity column reflection

Add SQL typing to reflection query used to retrieve a the structure
of IDENTITY columns, adding explicit JSON typing to the query to suit
unusual PostgreSQL driver configurations that don't support JSON natively.

Fixed issue affecting PostgreSQL 17.3 and greater where reflection of
domains with "NOT NULL" as part of their definition would include an
invalid constraint entry in the data returned by
:meth:`_postgresql.PGInspector.get_domains` corresponding to an additional
"NOT NULL" constraint that isn't a CHECK constraint; the existing
``"nullable"`` entry in the dictionary already indicates if the domain
includes a "not null" constraint.   Note that such domains also cannot be
reflected on PostgreSQL 17.0 through 17.2 due to a bug on the PostgreSQL
side; if encountering errors in reflection of domains which include NOT
NULL, upgrade to PostgreSQL server 17.3 or greater.

Fixes: #11751
Change-Id: I8e69de51601dca3257186e38c6f699fbfd9014c6

4 months agoMerge "group together with_polymorphic for single inh criteria" into main
Michael Bayer [Thu, 6 Mar 2025 18:35:06 +0000 (18:35 +0000)] 
Merge "group together with_polymorphic for single inh criteria" into main

4 months agorestate all upsert in terms of statement extensions (patch 3)
Mike Bayer [Mon, 24 Feb 2025 22:53:40 +0000 (17:53 -0500)] 
restate all upsert in terms of statement extensions (patch 3)

Change-Id: I0595ba8e2bd930e22f4c06d7a813bcd23060cb7a

4 months agoimplement mysql limit() for UPDATE/DELETE DML (patch 2)
Mike Bayer [Mon, 24 Feb 2025 20:10:54 +0000 (15:10 -0500)] 
implement mysql limit() for UPDATE/DELETE DML (patch 2)

Added new construct :func:`_mysql.limit` which can be applied to any
:func:`_sql.update` or :func:`_sql.delete` to provide the LIMIT keyword to
UPDATE and DELETE.  This new construct supersedes the use of the
"mysql_limit" dialect keyword argument.

Change-Id: Ie10c2f273432b0c8881a48f5b287f0566dde6ec3

4 months agoMerge "syntax extensions (patch 1)" into main
Michael Bayer [Thu, 6 Mar 2025 14:55:26 +0000 (14:55 +0000)] 
Merge "syntax extensions (patch 1)" into main

4 months agosyntax extensions (patch 1)
Mike Bayer [Mon, 16 Dec 2024 22:29:22 +0000 (17:29 -0500)] 
syntax extensions (patch 1)

Added the ability to create custom SQL constructs that can define new
clauses within SELECT, INSERT, UPDATE, and DELETE statements without
needing to modify the construction or compilation code of of
:class:`.Select`, :class:`.Insert`, :class:`.Update`, or :class:`.Delete`
directly.  Support for testing these constructs, including caching support,
is present along with an example test suite.  The use case for these
constructs is expected to be third party dialects for NewSQL or other novel
styles of database that introduce new clauses to these statements.   A new
example suite is included which illustrates the ``QUALIFY`` SQL construct
used by several NewSQL databases which includes a cachable implementation
as well as a test suite.

Since these extensions start to make it a bit crowded with how many
kinds of "options" we have on statements, did some naming /
documentation changes with existing constructs on Executable, in
particular to distinguish ExecutableOption from SyntaxExtension.

Fixes: #12195
Change-Id: I4a44ee5bbc3d8b1b640837680c09d25b1b7077af

4 months agoComplement type annotations for ARRAY
Denis Laxalde [Wed, 5 Mar 2025 20:59:39 +0000 (15:59 -0500)] 
Complement type annotations for ARRAY

### Description

This complements the type annotations of the `ARRAY` class, in preparation of #12384.

### Checklist

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.

Related to https://github.com/sqlalchemy/sqlalchemy/issues/6810

Closes: #12386
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12386
Pull-request-sha: c9513ce729fa1116b46b02336d4e2cda3d096fee

Change-Id: If9df4708c8e597eedc79ee3990792fa6c72f1afe

4 months agogroup together with_polymorphic for single inh criteria
Mike Bayer [Tue, 4 Mar 2025 16:31:10 +0000 (11:31 -0500)] 
group together with_polymorphic for single inh criteria

The behavior of :func:`_orm.with_polymorphic` when used with a single
inheritance mapping has been changed such that its behavior should match as
closely as possible to that of an equivalent joined inheritance mapping.
Specifically this means that the base class specified in the
:func:`_orm.with_polymorphic` construct will be the basemost class that is
loaded, as well as all descendant classes of that basemost class.
The change includes that the descendant classes named will no longer be
exclusively indicated in "WHERE polymorphic_col IN" criteria; instead, the
whole hierarchy starting with the given basemost class will be loaded.  If
the query indicates that rows should only be instances of a specific
subclass within the polymorphic hierarchy, an error is raised if an
incompatible superclass is loaded in the result since it cannot be made to
match the requested class; this behavior is the same as what joined
inheritance has done for many years. The change also allows a single result
set to include column-level results from multiple sibling classes at once
which was not previously possible with single table inheritance.

Fixes: #12395
Change-Id: I9307b236a6de8c47e452fb8f982098c54edb811a

4 months agoAdd type annotations to `postgresql.json`
Denis Laxalde [Tue, 4 Mar 2025 20:28:47 +0000 (15:28 -0500)] 
Add type annotations to `postgresql.json`

(Same as https://github.com/sqlalchemy/sqlalchemy/pull/12384, but for `json`.)

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

Related to #6810

**Have a nice day!**

Closes: #12391
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12391
Pull-request-sha: 0a43724f1737a4519629a13e2d6bf33f7aecb9ac

Change-Id: I2a0e88effccf351de7fa72389ee646532ce9cf69

4 months agotest related fixes
Federico Caselli [Wed, 5 Mar 2025 18:28:30 +0000 (19:28 +0100)] 
test related fixes

improve test error logging
add order to test

Change-Id: I2003f256a2690ee5673c72e2f1cb1340af750f83

4 months agoensure compiler is not optional in create_for_statement()
Mike Bayer [Mon, 3 Mar 2025 22:01:15 +0000 (17:01 -0500)] 
ensure compiler is not optional in create_for_statement()

this involved moving some methods around and changing the
target of legacy orm/query.py calling upon this method to
use an ORM-specific method instead

Change-Id: Ib977f08e52398d0e082acf7d88abecb9908ca8b6

5 months agoallow control of constraint isolation w/ add/drop constraint
Mike Bayer [Thu, 27 Feb 2025 17:04:12 +0000 (12:04 -0500)] 
allow control of constraint isolation w/ add/drop constraint

Added new parameters :paramref:`.AddConstraint.isolate_from_table` and
:paramref:`.DropConstraint.isolate_from_table`, defaulting to True, which
both document and allow to be controllable the long-standing behavior of
these two constructs blocking the given constraint from being included
inline within the "CREATE TABLE" sequence, under the assumption that
separate add/drop directives were to be used.

Fixes: #12382
Change-Id: I53c4170ccb5803f69945ba7aa3d3a143131508eb

5 months agoMerge "The ``noload`` loader option is now deprecated." into main
Michael Bayer [Thu, 27 Feb 2025 16:03:14 +0000 (16:03 +0000)] 
Merge "The ``noload`` loader option is now deprecated." into main

5 months agoMerge "improve rowmapping key type" into main
Michael Bayer [Thu, 27 Feb 2025 16:00:56 +0000 (16:00 +0000)] 
Merge "improve rowmapping key type" into main

5 months agoimprove rowmapping key type
Federico Caselli [Tue, 25 Feb 2025 22:06:55 +0000 (23:06 +0100)] 
improve rowmapping key type

the accepted keys are also orm attributes, column elements, functions
etc, not only columns

Change-Id: I354de9b9668bc02b8b305a3c1f065744b28f8030

5 months agoAdd more `requires` to tests for easier dialect tests management
Karol Gongola [Wed, 26 Feb 2025 10:06:16 +0000 (05:06 -0500)] 
Add more `requires` to tests for easier dialect tests management

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

### Description
<!-- Describe your changes in detail -->
I am just going through starrocks dialect tests. I have figured out that adding some requires for tests may be useful also for other dialects. So this is a proposal of adding them to sqlalchemy. Please let me know if it is aligned with your approach.

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

-->

This pull request is:

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

**Have a nice day!**

Closes: #12362
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12362
Pull-request-sha: 932d341f5f16f0c5cadc39d3a67b0f10297177ce

Change-Id: If9fa9f7477040620d131dcbe087fb4b50fd08a08

5 months agoMerge "various improvements to the docs" into main
Michael Bayer [Tue, 25 Feb 2025 20:43:34 +0000 (20:43 +0000)] 
Merge "various improvements to the docs" into main

5 months agovarious improvements to the docs
Federico Caselli [Mon, 24 Feb 2025 19:56:38 +0000 (20:56 +0100)] 
various improvements to the docs

- remove references to the removed mypy plugin
- add create table with partition examples in mysql

Change-Id: Idc5c35519a0812f1d63be95c14afb9ce2b00ea93

5 months agoRemove declarative_mixin
Federico Caselli [Mon, 24 Feb 2025 19:46:09 +0000 (20:46 +0100)] 
Remove declarative_mixin

Removed the ``declarative_mixin`` decorator since it was used only
by the now removed mypy plugin.

Fixes: #12346
Change-Id: I6709c7b33bf99ef94c3dc074a25386e8c13c9131

5 months agoThe ``noload`` loader option is now deprecated.
Federico Caselli [Fri, 24 Jan 2025 22:00:06 +0000 (23:00 +0100)] 
The ``noload`` loader option is now deprecated.

Fixes: #11045
Change-Id: If77517926eda71f92cd92b2d22a69a5ee172274e

5 months agofix docs typo
Federico Caselli [Mon, 24 Feb 2025 11:27:50 +0000 (12:27 +0100)] 
fix docs typo

Fixes: #12371
Change-Id: I86e6e34d407223d66b2cbcb21ec10dc292676449

5 months agoFix SQLite error for table with "WITHOUT ROWID" & "STRICT"
KingOfKaste [Thu, 20 Feb 2025 19:31:42 +0000 (14:31 -0500)] 
Fix SQLite error for table with "WITHOUT ROWID" & "STRICT"

Fixed issue that omitted the comma between multiple SQLite table extension
clauses, currently ``WITHOUT ROWID`` and ``STRICT``, when both options
:paramref:`.Table.sqlite_with_rowid` and  :paramref:`.Table.sqlite_strict`
were configured at their non-default settings at the same time.  Pull
request courtesy david-fed.

Fixes: #12368
Closes: #12369
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12369
Pull-request-sha: 3c9ceffe8279f5d961a44e6d468f21881bcbc75c

Change-Id: I1a44fd2d655d0e6eaad8213a360879daca9e4f11

5 months agocheck that two CTEs aren't just annotated forms of the same thing
Mike Bayer [Thu, 20 Feb 2025 17:50:25 +0000 (12:50 -0500)] 
check that two CTEs aren't just annotated forms of the same thing

Fixed issue where using :func:`_orm.aliased` around a :class:`.CTE`
construct could cause inappropriate "duplicate CTE" errors in cases where
that aliased construct appeared multiple times in a single statement.

Fixes: #12364
Change-Id: I9625cd83e9baf5312cdc644b38951353708d3b86

5 months agoMerge "apply _propagate_attrs in _construct_for_list" into main
Michael Bayer [Tue, 18 Feb 2025 17:57:10 +0000 (17:57 +0000)] 
Merge "apply _propagate_attrs in _construct_for_list" into main

5 months agoMerge "Support generic types for union and union_all" into main
Michael Bayer [Tue, 18 Feb 2025 17:18:19 +0000 (17:18 +0000)] 
Merge "Support generic types for union and union_all" into main

5 months agoapply _propagate_attrs in _construct_for_list
Mike Bayer [Tue, 18 Feb 2025 15:20:32 +0000 (10:20 -0500)] 
apply _propagate_attrs in _construct_for_list

Fixed issue where the "is ORM" flag of a :func:`.select` or other ORM
statement would not be propagated to the ORM :class:`.Session` based on a
multi-part operator expression alone, e.g. such as ``Cls.attr + Cls.attr +
Cls.attr`` or similar, leading to ORM behaviors not taking place for such
statements.

Fixes: #12357
Change-Id: I61130eeb3c7a32c1830731fd9ad4eb99a64abf7d

5 months agoInclude status in the Pool docs
Federico Caselli [Mon, 17 Feb 2025 20:11:50 +0000 (21:11 +0100)] 
Include status in the Pool docs

Change-Id: I0a4bfc10f4cd0b7dbd3bf49e0575048b622fa4e8

5 months agominor docs fixes
Federico Caselli [Thu, 13 Feb 2025 22:17:12 +0000 (23:17 +0100)] 
minor docs fixes

Change-Id: I7379bc6904daac711063734d2f43aa5f6e734a0f

5 months agoMerge "Default python_type impl now returns object" into main
Michael Bayer [Thu, 13 Feb 2025 16:31:56 +0000 (16:31 +0000)] 
Merge "Default python_type impl now returns object" into main

5 months agoDefault python_type impl now returns object
Federico Caselli [Wed, 5 Feb 2025 22:41:32 +0000 (23:41 +0100)] 
Default python_type impl now returns object

The default implementation of :attr:`_sql.TypeEngine.python_type` now
returns ``object`` instead of ``NotImplementedError``, since that's the
base for all types in Python3.
The ``python_type`` of :class:`_sql.JSON` no longer returns ``dict``,
but instead fallbacks to the generic implementation.

Fixes: #10646
Change-Id: I2233e4a3d35a67b520a860d70afba8e5b22fd72d

5 months agoSupport generic types for union and union_all
Mingyu Park [Fri, 7 Feb 2025 19:45:26 +0000 (14:45 -0500)] 
Support generic types for union and union_all

Support generic types for compound selects (:func:`_sql.union`,
:func:`_sql.union_all`, :meth:`_sql.Select.union`,
:meth:`_sql.Select.union_all`, etc) returning the type of the first select.

Fixes: #11922
Closes: #12320
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12320
Pull-request-sha: f914a19f7201cec292056e900436d8c8431b9f87

Change-Id: I4fffa5d3fe93dd3a293b078360e326fea4207c5d

5 months agofix(AsyncResult): Fix scalar method error due to missing attribute
allenyuchen [Wed, 12 Feb 2025 17:35:58 +0000 (12:35 -0500)] 
fix(AsyncResult): Fix scalar method error due to missing attribute

Fixed bug where :meth:`_asyncio.AsyncResult.scalar`,
:meth:`_asyncio.AsyncResult.scalar_one_or_none`, and
:meth:`_asyncio.AsyncResult.scalar_one` would raise an ``AttributeError``
due to a missing internal attribute.  Pull request courtesy Allen Ho.

Fixes: #12338
Closes: #12339
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12339
Pull-request-sha: 63ba43365e9624a75e3f206e6b0f4569e3940da6

Change-Id: I44a949e4a942a080338037cd570d4b1dc0d7550d

5 months agoMerge "try pytest 8.3" into main
Michael Bayer [Tue, 11 Feb 2025 02:20:12 +0000 (02:20 +0000)] 
Merge "try pytest 8.3" into main

5 months agoreconcile #12326 and #12328
Mike Bayer [Mon, 10 Feb 2025 20:26:24 +0000 (15:26 -0500)] 
reconcile #12326 and #12328

These two issues both involve ORM DML RETURNING.   The looser
column inclusion rules given in #12328 then included a correlated
subquery column_property given in #12326, which does not work
in RETURNING.  so re-tighten UPDATE/DELETE with a more specific
rule to cut out local mapped props that are not persisted columns,
but still allow other mapped props through without blocking them.

Fixes: #12326
Change-Id: I8fe7b8ab9b85907e562648433fdb3c7ba160c0d0

5 months agoMerge "implement is_derived_from() for DML" into main
Michael Bayer [Mon, 10 Feb 2025 13:20:12 +0000 (13:20 +0000)] 
Merge "implement is_derived_from() for DML" into main

5 months agoonly use _DMLReturningColFilter for "bulk insert", not other DML
Mike Bayer [Sun, 9 Feb 2025 23:09:21 +0000 (18:09 -0500)] 
only use _DMLReturningColFilter for "bulk insert", not other DML

Fixed bug in ORM enabled UPDATE (and theoretically DELETE) where using a
multi-table DML statement would not allow ORM mapped columns from mappers
other than the primary UPDATE mapper to be named in the RETURNING clause;
they would be omitted instead and cause a column not found exception.

Fixes: #12328
Change-Id: I2223ee506eec447823a3a545eecad1a7a03364a9

5 months agotry pytest 8.3
Mike Bayer [Sun, 9 Feb 2025 23:30:11 +0000 (18:30 -0500)] 
try pytest 8.3

we've been pinned under 8.2 for unclear reasons (but likely
reasons).   see what 8.3 does.  current pypi release is 8.3.4

Change-Id: I601335f5604a37e07fd3bb0abb99160e055dd95c

5 months agoimplement is_derived_from() for DML
Mike Bayer [Sat, 8 Feb 2025 16:38:53 +0000 (11:38 -0500)] 
implement is_derived_from() for DML

Fixed bug where using DML returning such as :meth:`.Insert.returning` with
an ORM model that has :func:`_orm.column_property` constructs that contain
subqueries would fail with an internal error.

Fixes: #12326
Change-Id: I419f645769a346c229944b30ac8fd4a0efe1646d

5 months agoMerge "Deprecate objects param of flush" into main
Federico Caselli [Sat, 8 Feb 2025 10:56:46 +0000 (10:56 +0000)] 
Merge "Deprecate objects param of flush" into main

5 months agoDeprecate objects param of flush
Federico Caselli [Wed, 5 Feb 2025 21:38:08 +0000 (22:38 +0100)] 
Deprecate objects param of flush

The :paramref:`_orm.Session.flush.objects` parameter is now deprecated.

Fixes: #10816
Change-Id: I4a535e91aefa16774c2549ecec09113d6e669df4

5 months agodoc(reconecting_engine): fix re-raise after attempts (#12306)
Augustin Prolongeau [Thu, 6 Feb 2025 23:18:57 +0000 (00:18 +0100)] 
doc(reconecting_engine): fix re-raise after attempts (#12306)

* doc(reconecting_engine): fix re-raise after attempts

* move re-raise after connection invalidation/rollback, reword log message

5 months agocherry-pick changelog update for 2.0.39
Mike Bayer [Thu, 6 Feb 2025 20:10:27 +0000 (15:10 -0500)] 
cherry-pick changelog update for 2.0.39

5 months agocherry-pick changelog from 2.0.38
Mike Bayer [Thu, 6 Feb 2025 20:10:27 +0000 (15:10 -0500)] 
cherry-pick changelog from 2.0.38

5 months agothis is version 2.0.38
Mike Bayer [Thu, 6 Feb 2025 20:04:30 +0000 (15:04 -0500)] 
this is version 2.0.38

Change-Id: I784d0ba9e4afd9a7be6dac71cd04376dedbec211

5 months agochangelog edits
Mike Bayer [Thu, 6 Feb 2025 18:59:22 +0000 (13:59 -0500)] 
changelog edits

Change-Id: I61164f4af388d8f4f157ad6afe96ccbb668587a7

5 months agoMerge "remove None exception in IN" into main
Michael Bayer [Thu, 6 Feb 2025 15:14:43 +0000 (15:14 +0000)] 
Merge "remove None exception in IN" into main

5 months agoMerge "reorganize column collection init to be local" into main
Michael Bayer [Wed, 5 Feb 2025 20:56:25 +0000 (20:56 +0000)] 
Merge "reorganize column collection init to be local" into main

5 months agoMerge "Use AsyncAdaptedQueuePool in aiosqlite" into main
Michael Bayer [Wed, 5 Feb 2025 19:17:29 +0000 (19:17 +0000)] 
Merge "Use AsyncAdaptedQueuePool in aiosqlite" into main

5 months agoremove None exception in IN
Mike Bayer [Wed, 5 Feb 2025 13:37:04 +0000 (08:37 -0500)] 
remove None exception in IN

Fixed SQL composition bug which impacted caching where using a ``None``
value inside of an ``in_()`` expression would bypass the usual "expanded
bind parameter" logic used by the IN construct, which allows proper caching
to take place.

Fixes: #12314
References: #12312
Change-Id: I0d2fc4e15c73407379ba368dd4ee32660fc66259

5 months agoMerge "Added `merge_all` and `delete_all`" into main
Michael Bayer [Wed, 5 Feb 2025 19:05:44 +0000 (19:05 +0000)] 
Merge "Added `merge_all` and `delete_all`" into main

5 months agoreorganize column collection init to be local
Mike Bayer [Sat, 1 Feb 2025 19:39:57 +0000 (14:39 -0500)] 
reorganize column collection init to be local

Reorganized the internals by which the `.c` collection on a
:class:`.FromClause` gets generated so that it is resilient against the
collection being accessed in concurrent fashion.   An example is creating a
:class:`.Alias` or :class:`.Subquery` and accessing it as a module level
variable.  This impacts the Oracle dialect which uses such module-level
global alias objects but is of general use as well.

Fixes: #12302
Change-Id: I30cb07c286affce24e2d85e49f9df5b787438d86

5 months agoFix 'polymorphic' typo in a few places (#12307)
Martin Burchell [Mon, 3 Feb 2025 18:56:55 +0000 (18:56 +0000)] 
Fix 'polymorphic' typo in a few places (#12307)

5 months agoAdded `merge_all` and `delete_all`
Federico Caselli [Fri, 3 Jan 2025 20:42:48 +0000 (21:42 +0100)] 
Added `merge_all` and `delete_all`

Added the utility method :meth:`_orm.Session.merge_all` and
:meth:`_orm.Session.delete_all` that operate on a collection
of instances.

Fixes: #11776
Change-Id: Ifd70ba2850db7c5e7aee482799fd65c348c2899a

5 months agoMerge "Unable to use InstrumentedAttribute to value mappings in mysql/mariadb on_dupl...
Federico Caselli [Sat, 1 Feb 2025 20:50:04 +0000 (20:50 +0000)] 
Merge "Unable to use InstrumentedAttribute to value mappings in mysql/mariadb on_duplicate_key_update" into main

5 months agoUnable to use InstrumentedAttribute to value mappings in mysql/mariadb on_duplicate_k...
Mingyu Park [Sat, 1 Feb 2025 07:43:35 +0000 (02:43 -0500)] 
Unable to use InstrumentedAttribute to value mappings in mysql/mariadb on_duplicate_key_update

Fixes: #12117
Closes: #12296
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12296
Pull-request-sha: 32a09ebd18a6f97fdb23cc8a8e212342e6c26291

Change-Id: I72701f63b13105e5dc36e63ba2651da2673f1735

5 months agoUse AsyncAdaptedQueuePool in aiosqlite
Christophe Bornet [Fri, 31 Jan 2025 12:42:59 +0000 (07:42 -0500)] 
Use AsyncAdaptedQueuePool in aiosqlite

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

### Description
Change default pool in `aiosqlite` from `NullPool` to `AsyncAdaptedQueuePool`.
This ensures consistency with pysqlite and least surprise when migrating from sync to async.
See discussion in https://github.com/sqlalchemy/sqlalchemy/discussions/12285
Non regression tested by existing tests.

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

**Have a nice day!**

Closes: #12291
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12291
Pull-request-sha: 5a0872b8d431a6937eaf05fb132578aed5723b6a

Change-Id: I96b4d0b5154b34cd26d3ad89774229b0f5d8686f

5 months agoRemoved the deprecated mypy plugin.
Federico Caselli [Thu, 30 Jan 2025 21:05:59 +0000 (22:05 +0100)] 
Removed the deprecated mypy plugin.

The plugin was non-functional with newer version of mypy and it's no
longer needed with modern SQLAlchemy declarative style.

Fixes: #12293
Change-Id: If4581ab58623f0a2992f4e33a6dcdae002c68dad

5 months agoMerge "Skip mypy plugin tests if incompatible or missing" into main
Federico Caselli [Thu, 30 Jan 2025 20:39:34 +0000 (20:39 +0000)] 
Merge "Skip mypy plugin tests if incompatible or missing" into main

5 months agoremove comma in docstring
Federico Caselli [Thu, 30 Jan 2025 20:34:00 +0000 (21:34 +0100)] 
remove comma in docstring

Change-Id: I135c06ddc16f905835b50cb8ea41f13a1ae2e0be

5 months agoFix typo python2 -> python in 2.0 major migration guide (#12250)
Martin Burchell [Thu, 30 Jan 2025 20:31:15 +0000 (20:31 +0000)] 
Fix typo python2 -> python in 2.0 major migration guide (#12250)

5 months agoSkip mypy plugin tests if incompatible or missing
Nils Philippsen [Thu, 30 Jan 2025 13:10:55 +0000 (08:10 -0500)] 
Skip mypy plugin tests if incompatible or missing

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

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

This skips Mypy plugin tests if mypy is missing or an unsupported version.

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

**Have a nice day!**

Closes: #12288
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12288
Pull-request-sha: 00e00f321d54da3e5d6112f61d5770e59e33bf82

Change-Id: I492a93d3c586425e2cf53304520164dc1487a667

6 months agosupport accept for chains of joineddispatchers
Mike Bayer [Wed, 29 Jan 2025 15:10:09 +0000 (10:10 -0500)] 
support accept for chains of joineddispatchers

Fixed issue where creating an :class:`.Engine` using multiple calls to
:meth:`.Engine.execution_options` where a subsequent call involved certain
options such as ``isolation_level`` would lead to an internal error
involving event registration.

Fixes: #12289
Change-Id: Iec5fbc0eb0c5a92dda1ea762872ae992ca816685

6 months agoRemoved executable coercion
Federico Caselli [Sat, 4 Jan 2025 09:21:08 +0000 (10:21 +0100)] 
Removed executable coercion

Removed the automatic coercion of executable objects, such as
:class:`_orm.Query`, when passed into :meth:`_orm.Session.execute`.
This usage raised a deprecation warning since the 1.4 series.

Fixes: #12218
Change-Id: Iaab3116fcc8d957ff3f14e84a4ece428fd176b8b

6 months agouse arm runnes on linux instead of emulation
Federico Caselli [Wed, 22 Jan 2025 20:00:41 +0000 (21:00 +0100)] 
use arm runnes on linux instead of emulation

Fixes: #12249
Change-Id: I4c56a10d09716aa5e1fc4a1688dbfdf7cfcfd2fb

6 months agodocument name normalize
Mike Bayer [Wed, 4 Dec 2024 14:22:14 +0000 (09:22 -0500)] 
document name normalize

Fixes: #10789
Change-Id: I795d92c900502e4b2fde7ab11e8adb9b03d5b782

6 months agoMerge "asyncpg: shield connection close in terminate to avoid connection leak" into...
Michael Bayer [Tue, 21 Jan 2025 00:35:03 +0000 (00:35 +0000)] 
Merge "asyncpg: shield connection close in terminate to avoid connection leak" into main

6 months agoset default iso to None for asyncpg pep-249 wrapper
Mike Bayer [Thu, 16 Jan 2025 17:14:02 +0000 (12:14 -0500)] 
set default iso to None for asyncpg pep-249 wrapper

Adjusted the asyncpg connection wrapper so that the asyncpg
``.transaction()`` call sends ``None`` for isolation_level if not otherwise
set in the SQLAlchemy dialect/wrapper, thereby allowing asyncpg to make use
of the server level setting for isolation_level in the absense of a
client-level setting. Previously, this behavior of asyncpg was blocked by a
hardcoded ``read_committed``.

Fixes: #12159
Change-Id: I2cd878a5059a8fefc9557a9b8e056fedaee2e9a4

6 months agoasyncpg: shield connection close in terminate to avoid connection leak
Federico Caselli [Fri, 17 Jan 2025 20:16:51 +0000 (21:16 +0100)] 
asyncpg: shield connection close in terminate to avoid connection leak

Added an additional ``shield()`` call within the connection terminate
process of the asyncpg driver, to mitigate an issue where terminate would
be prevented from completing under the anyio concurrency library.

Fixes #12077
Closes: #12076
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12076
Pull-request-sha: 6ae261ea7668f4c850874666efec6fef658b08c0

Change-Id: Iaec63d02b620201dc60ffdad76ba9d61d427cac1

6 months agoupdate logging_name doc
Mike Bayer [Mon, 13 Jan 2025 13:14:14 +0000 (08:14 -0500)] 
update logging_name doc

engine logging has not used hex-strings in a very long time

Change-Id: I77131e3eb2f72129fde1d9ab6dd4b4e40bc313c6

6 months agoMerge "Remove fallbacks from the previous typing change" into main
Federico Caselli [Sun, 12 Jan 2025 19:00:38 +0000 (19:00 +0000)] 
Merge "Remove fallbacks from the previous typing change" into main

6 months agoREADME.unittests: fixup for parallelized `pytest` example (#12242)
James Addison [Sat, 11 Jan 2025 22:03:56 +0000 (22:03 +0000)] 
README.unittests: fixup for parallelized `pytest` example (#12242)

6 months agofix linter warning
Federico Caselli [Sat, 11 Jan 2025 21:59:06 +0000 (22:59 +0100)] 
fix linter warning

Change-Id: I075cfff5c9aea58d29c2caf5fd7512faa4902ef4

6 months agoFix MovedIn20Warning docstring (#12237)
Juang, Yi-Lin [Fri, 10 Jan 2025 22:27:49 +0000 (15:27 -0700)] 
Fix MovedIn20Warning docstring (#12237)

Remove reference of RemovedIn20Warning

6 months agocherry-pick changelog update for 2.0.38
Mike Bayer [Thu, 9 Jan 2025 22:44:09 +0000 (17:44 -0500)] 
cherry-pick changelog update for 2.0.38

6 months agocherry-pick changelog from 2.0.37
Mike Bayer [Thu, 9 Jan 2025 22:44:09 +0000 (17:44 -0500)] 
cherry-pick changelog from 2.0.37