]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
13 months agoCorrect 'Session.is_modified' method documentation 11501/head
Roman Druzhkov [Sun, 16 Jun 2024 16:52:35 +0000 (20:52 +0400)] 
Correct 'Session.is_modified' method documentation

(cherry picked from commit 3cdd3f65f00159f85bfa8f01d52861105d776871)

13 months agoMerge "open up async greenlet for third parties" into rel_2_0
Michael Bayer [Thu, 13 Jun 2024 17:33:09 +0000 (17:33 +0000)] 
Merge "open up async greenlet for third parties" into rel_2_0

13 months agostrongly discourage noload
Mike Bayer [Thu, 13 Jun 2024 14:04:01 +0000 (10:04 -0400)] 
strongly discourage noload

Change-Id: I54a1c1d29b33091838b7f3fcd46eeec48bbd498b

13 months agoopen up async greenlet for third parties
Mike Bayer [Wed, 12 Jun 2024 16:42:29 +0000 (12:42 -0400)] 
open up async greenlet for third parties

Modified the internal representation used for adapting asyncio calls to
greenlets to allow for duck-typed compatibility with third party libraries
that implement SQLAlchemy's "greenlet-to-asyncio" pattern directly.
Running code within a greenlet that features the attribute
``__sqlalchemy_greenlet_provider__ = True`` will allow calls to
:func:`sqlalchemy.util.await_only` directly.

Change-Id: I79c67264e1a642b9a80d3b46dc64bdda80acf0aa
(cherry picked from commit c1e2d9180a14c74495b712e08d8156b92f907ac0)

13 months agoMerge "include HasCTE traversal elements in TextualSelect" into rel_2_0
Michael Bayer [Thu, 13 Jun 2024 13:26:20 +0000 (13:26 +0000)] 
Merge "include HasCTE traversal elements in TextualSelect" into rel_2_0

13 months agoBump pypa/cibuildwheel from 2.17.0 to 2.19.0 (#11474)
dependabot[bot] [Tue, 11 Jun 2024 21:59:19 +0000 (23:59 +0200)] 
Bump pypa/cibuildwheel from 2.17.0 to 2.19.0 (#11474)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.17.0 to 2.19.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.17.0...v2.19.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit b320b04af2eb247c3466ac446f138add5eddb3b6)

13 months agoloosen up hash_limit test
Mike Bayer [Tue, 11 Jun 2024 13:16:26 +0000 (09:16 -0400)] 
loosen up hash_limit test

hash_limit_string works by doing a modulus of a hash value so that
the range of possible numbers is 0-N.  however, there's a chance
we might not populate every 0-N value in unusual cases on CI,
even after iterating 500 times apparently.  Loosen the change by making
sure we got at least N/2 unique hash messages but not greater
than N.

Change-Id: I5cd2845697ec0a718ddca1c95fbc4867b06eabee
(cherry picked from commit ef04a401100ff37915c281c412ed3d784565e429)

13 months agoinclude HasCTE traversal elements in TextualSelect
Mike Bayer [Tue, 11 Jun 2024 02:59:49 +0000 (22:59 -0400)] 
include HasCTE traversal elements in TextualSelect

Fixed caching issue where using the :meth:`.TextualSelect.add_cte` method
of the :class:`.TextualSelect` construct would not set a correct cache key
which distinguished between different CTE expressions.

Fixes: #11471
Change-Id: Ia9ce2c8cfd128f0f130aa9b26448dc23d994c324
(cherry picked from commit faecebc9df2a57173ee720973ba44ada370b682f)

13 months agoMerge "add additional contextual path info when splicing eager joins" into rel_2_0
Michael Bayer [Sat, 8 Jun 2024 14:43:52 +0000 (14:43 +0000)] 
Merge "add additional contextual path info when splicing eager joins" into rel_2_0

13 months agoMerge "Document InstanceState modified and expired." into rel_2_0
Michael Bayer [Thu, 6 Jun 2024 13:53:08 +0000 (13:53 +0000)] 
Merge "Document InstanceState modified and expired." into rel_2_0

14 months agoadd additional contextual path info when splicing eager joins
Mike Bayer [Tue, 4 Jun 2024 14:56:26 +0000 (10:56 -0400)] 
add additional contextual path info when splicing eager joins

Fixed very old issue involving the :paramref:`_orm.joinedload.innerjoin`
parameter where making use of this parameter mixed into a query that also
included joined eager loads along a self-referential or other cyclical
relationship, along with complicating factors like inner joins added for
secondary tables and such, would have the chance of splicing a particular
inner join to the wrong part of the query.  Additional state has been added
to the internal method that does this splice to make a better decision as
to where splicing should proceed.

Fixes: #11449
Change-Id: Ie8f0e8d9bb7958baac33c7c2231e4afae15cf5b1
(cherry picked from commit c4c57237b76f3992a62c6eb5c23fd4e1919f1e4a)

14 months agoexpand entity_isa to include simple "isa" in poly case
Mike Bayer [Mon, 3 Jun 2024 18:50:25 +0000 (14:50 -0400)] 
expand entity_isa to include simple "isa" in poly case

Fixed issue where the :func:`_orm.selectinload` and
:func:`_orm.subqueryload` loader options would fail to take effect when
made against an inherited subclass that itself included a subclass-specific
:paramref:`_orm.Mapper.with_polymorphic` setting.

Fixes: #11446
Change-Id: I2df3ebedbe4aa9da58af99d7729e5f3052ad6abc
(cherry picked from commit 63a903b918343ca312aaded93b7e9af7a88fa3a8)

14 months agoMerge "Add missing function element methods" into rel_2_0
Michael Bayer [Mon, 3 Jun 2024 14:25:01 +0000 (14:25 +0000)] 
Merge "Add missing function element methods" into rel_2_0

14 months agoMerge "Make `FunctionFilter.filter` generative" into rel_2_0
Michael Bayer [Mon, 3 Jun 2024 14:19:12 +0000 (14:19 +0000)] 
Merge "Make `FunctionFilter.filter` generative" into rel_2_0

14 months agoDocument InstanceState modified and expired.
Federico Caselli [Sun, 2 Jun 2024 09:51:31 +0000 (11:51 +0200)] 
Document InstanceState modified and expired.

Fixes: #11431
Change-Id: Iff762b0c14db5b8851ea8fa20f4304c0cc6657de
(cherry picked from commit c1cc8793388214351ab0ccead9616c80458c5bb9)

14 months agoMake `FunctionFilter.filter` generative
Federico Caselli [Wed, 29 May 2024 19:39:08 +0000 (21:39 +0200)] 
Make `FunctionFilter.filter` generative

Fixed bug in :meth:`_sql.FunctionFilter.filter` that would mutate
the existing function in-place. It now behaves like the rest of the
SQLAlchemy API, returning a new instance instead of mutating the
original one.

Fixes: #11426
Change-Id: I46ffebaed82426cfb1623db066686cfb911055a1
(cherry picked from commit fe2ced9e79b9640f3ca135f8d3782dd41ca16782)

14 months agoAdd missing function element methods
Federico Caselli [Wed, 29 May 2024 20:18:50 +0000 (22:18 +0200)] 
Add missing function element methods

Added missing methods :meth:`_sql.FunctionFilter.within_group`
and :meth:`_sql.WithinGroup.filter`

Fixes: #11423
Change-Id: I4bafd9e3cab5883b28b2b997269df239739a2212
(cherry picked from commit 57bba096599ff10be008283261054e46c9d08d0b)

14 months agoMerge "Add test for issue 11412" into rel_2_0
Michael Bayer [Thu, 30 May 2024 17:36:59 +0000 (17:36 +0000)] 
Merge "Add test for issue 11412" into rel_2_0

14 months agoFix Over serialization
Federico Caselli [Wed, 29 May 2024 20:03:17 +0000 (22:03 +0200)] 
Fix Over serialization

Fixed issue when serializing an :func:`_sql.over` clause with
unbounded range or rows.

Fixes: #11422
Change-Id: I52a9f72205fd9c7ef5620596c83551e73d5cee5b
(cherry picked from commit 9f4f84ffdc1be487930b00d0b190bd492d302ca1)

14 months agoskip dunders for langhelper symbol redefine; update tox
Mike Bayer [Sun, 26 May 2024 15:34:27 +0000 (11:34 -0400)] 
skip dunders for langhelper symbol redefine; update tox

Set up full Python 3.13 support to the extent currently possible, repairing
issues within internal language helpers as well as the serializer extension
module.

update tox for what will be a regular condition: greenlet is
not available (and possibly other things like pymssql):

1. dont use "sqlalchemy[asyncio]" in pyproejct.toml as an extra; this
   goes out to pypi and ignores the local file
2. add py{3,38,39,...} qualifiers for asyncio deps in tox.ini.   After
   many attempts I seem to have something that's fairly non-repetetive
   though I'd still prefer a single variable for this, somehow

Fixes: #11417
Change-Id: Ib2ceccd9583d8776700f0da5b591906efcfe6e6f
(cherry picked from commit 577b53c70993a496aa4149adc477e0732310dd7d)

14 months agoAdd test for issue 11412
Mike Bayer [Fri, 24 May 2024 14:58:02 +0000 (10:58 -0400)] 
Add test for issue 11412

Issue #10365 was found to also fix an issue where
single-inheritance criteria would not be correctly applied to a
subclass entity that only appeared in the ``select_from()`` list.

Fixes: #11412
Change-Id: Ic865737a3d075fceee346eea8044345233038f72
(cherry picked from commit 61d227a7d4f7be7b1f6fa72171d01c60e571939e)

14 months agoMerge "Improve implementation of server side cursor in asyncpg" into rel_2_0
Michael Bayer [Wed, 22 May 2024 15:28:14 +0000 (15:28 +0000)] 
Merge "Improve implementation of server side cursor in asyncpg" into rel_2_0

14 months agoMerge "Add ``SET DEFAULT`` reflection option" into rel_2_0
Michael Bayer [Wed, 22 May 2024 15:20:51 +0000 (15:20 +0000)] 
Merge "Add ``SET DEFAULT`` reflection option" into rel_2_0

14 months agoMerge "Optimize has_intersection func" into rel_2_0
Michael Bayer [Wed, 22 May 2024 15:19:33 +0000 (15:19 +0000)] 
Merge "Optimize has_intersection func" into rel_2_0

14 months agoOptimize has_intersection func
Semyon Pupkov [Sat, 11 May 2024 12:41:06 +0000 (08:41 -0400)] 
Optimize has_intersection func

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

Optimize `has_intersection` function.  It uses in few places, but even so it might be optimized. New version:
1. Does not allocate new set
2. A bit of performance speedup
```
from sqlalchemy import util

import timeit
import functools

a = {1, 2, 3}
b = [2, 3, 4]

t1 = timeit.Timer(functools.partial(util.has_intersection, a, b))
t2 = timeit.Timer(functools.partial(util.has_intersection2, a, b))

print("old", t1.timeit())
print("new", t2.timeit())

old 0.37196154199773446
new 0.29704541599494405

old 0.37331208398973104
new 0.29647241700149607
```

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

- [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: #11378
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11378
Pull-request-sha: 258bf1af7c73c83502eb49240a996f5846c6a0a9

Change-Id: Ic1ec1448641304eba4751f55f1e3c2b217f7f352
(cherry picked from commit 5b43687da6820884c75531e89d6347bf285a3b2c)

14 months agoAdd ``insert_default`` to ``Column``.
Federico Caselli [Thu, 9 May 2024 20:21:11 +0000 (22:21 +0200)] 
Add ``insert_default`` to ``Column``.

Added :paramref:`_schema.Column.insert_default` as an alias of
:paramref:`_schema.Column.default` for compatibility with
func:`_orm.mapped_column`.

Fixes: #11374
Change-Id: I5509b6cbac7b37ac37430a88442b1319cc9c1024
(cherry picked from commit c87572b60cbcb869c41a7b4283a11c5c14ef048c)

14 months agoAdd ``SET DEFAULT`` reflection option
roche-quentin [Wed, 8 May 2024 10:48:09 +0000 (06:48 -0400)] 
Add ``SET DEFAULT`` reflection option

Added missing foreign key reflection option ``SET DEFAULT``
in the MySQL and MariaDB dialects.

Fixes: #11285
Closes: #11368
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11368
Pull-request-sha: dbd9c239c60b8f4f2be66967825ee15c1f7941b0

Change-Id: If61d3365fc4271432d5591d1b50e10f4a1da9290
(cherry picked from commit 323a7dcb5e70ae555e771beb63e3a58158f003a2)

14 months agosetup JoinedDispatch to support pickling
Mike Bayer [Tue, 7 May 2024 22:03:51 +0000 (18:03 -0400)] 
setup JoinedDispatch to support pickling

Fixed issue where a :class:`.MetaData` collection would not be
serializable, if an :class:`.Enum` or :class:`.Boolean` datatype were
present which had been adapted. This specific scenario in turn could occur
when using the :class:`.Enum` or :class:`.Boolean` within ORM Annotated
Declarative form where type objects frequently get copied.

Fixes: #11365
Change-Id: Iaaa64baad79c41075d37cf53dade744d79e600a3
(cherry picked from commit 93cfb49572ac56bc320a09b82285bf8ef8cdff57)

14 months agoAdd name parameter to with_polymorphic.
Federico Caselli [Mon, 6 May 2024 21:10:46 +0000 (23:10 +0200)] 
Add name parameter to with_polymorphic.

Added missing parameter :paramref:`_orm.with_polymorphic.name` that
allows specifying the name of returned :class:`_orm.AliasedClass`.

Fixes: #11361
Change-Id: I1eae550452526d85da1377207c5fa5e93ac673c3
(cherry picked from commit 02001e9458802ebb512a140aa24e663b364dc3ad)

14 months agoImprove implementation of server side cursor in asyncpg
Federico Caselli [Sat, 4 May 2024 20:12:28 +0000 (22:12 +0200)] 
Improve implementation of server side cursor in asyncpg

Change-Id: I36d0ff5ccea7fbf46cabcfeae1492b9a90b7f68b
(cherry picked from commit e3571e1d4b4d34a250886a8967a9b1339f0c68a7)

15 months agoVersion 2.0.31 placeholder
Mike Bayer [Sun, 5 May 2024 18:04:18 +0000 (14:04 -0400)] 
Version 2.0.31 placeholder

15 months ago- 2.0.30 rel_2_0_30
Mike Bayer [Sun, 5 May 2024 17:52:32 +0000 (13:52 -0400)] 
- 2.0.30

15 months agotypo fixes
Mike Bayer [Sun, 5 May 2024 17:15:57 +0000 (13:15 -0400)] 
typo fixes

Change-Id: I8f3a1d755d03e6c11fa1f783f111977b7ddc22fb
(cherry picked from commit 96a50e381ed97dfa92900e3212e1598bc99123a7)

15 months agoMerge "Updated typing for self_group()" into rel_2_0
Michael Bayer [Sun, 5 May 2024 15:43:12 +0000 (15:43 +0000)] 
Merge "Updated typing for self_group()" into rel_2_0

15 months agoMerge "Add overload for ColumnCollection.get(col, default)" into rel_2_0
Michael Bayer [Sun, 5 May 2024 15:32:40 +0000 (15:32 +0000)] 
Merge "Add overload for ColumnCollection.get(col, default)" into rel_2_0

15 months agorevise approach for bundle deduping
Mike Bayer [Sat, 4 May 2024 14:38:48 +0000 (10:38 -0400)] 
revise approach for bundle deduping

Revise the approach from 7d6d7ef73 to make a special case for
Bundle-targeted columns entirely, and don't involve the
_label_convention() callable.   Add tests for select() with
tablename labeling convention.

Fixes: #11347
Change-Id: I1d15523de5709d45b2b69bc17724831ac3425791
(cherry picked from commit 83f8dd53e362c3ea7562c0076add044740d2c4cc)

15 months agoUpdated typing for self_group()
Federico Caselli [Sat, 4 May 2024 09:23:52 +0000 (11:23 +0200)] 
Updated typing for self_group()

Fixes: #10939
Closes: #11037
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11037
Pull-request-sha: 3ebf4db506ffef629f938f4f36fc76d6671b98e1

Change-Id: I22218286b0dac7bafaaf6955557e25f99a6aefe1
(cherry picked from commit 7173b047788f8a4230647bfc252037c6e227c708)

15 months agoAdd overload for ColumnCollection.get(col, default)
Mark Elliot [Mon, 29 Apr 2024 21:50:10 +0000 (17:50 -0400)] 
Add overload for ColumnCollection.get(col, default)

### Description
Fixes #11328 by adding an overload to ColumnCollection when a non-None default is provided.

### Checklist
This pull request is:

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

Closes: #11329
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11329
Pull-request-sha: 32db849e0df1db357df79df3a0dc2263a755d04e

Change-Id: I8bef91c423fb7048ec8d4a7c99f70f0b1588c37a
(cherry picked from commit ab6df37dad5cccbd0328e83ed55c7cfed91344cb)

15 months agoMerge "disable col deduping inside of Bundle" into rel_2_0
Federico Caselli [Sat, 4 May 2024 08:11:00 +0000 (08:11 +0000)] 
Merge "disable col deduping inside of Bundle" into rel_2_0

15 months agoBump pypa/cibuildwheel from 2.16.5 to 2.17.0 (#11148)
dependabot[bot] [Sat, 4 May 2024 08:09:30 +0000 (10:09 +0200)] 
Bump pypa/cibuildwheel from 2.16.5 to 2.17.0 (#11148)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.16.5 to 2.17.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.16.5...v2.17.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit 8e1e980b50b0be71f641bca7d81d32fef6565612)

15 months agoUpdate index.rst to include MariaDB (#11337)
Robert Silén [Sat, 4 May 2024 08:06:32 +0000 (11:06 +0300)] 
Update index.rst to include MariaDB (#11337)

Changing title of link to "dialects/mysql" to read "MySQL and MariaDB" to match the actual title of the page. (before link says just MySQL)

(cherry picked from commit 000f1832700fc28cae5fe9f3d7356835095052bb)

15 months agoMerge "improve pep-695 inference including Enum support" into rel_2_0
Federico Caselli [Sat, 4 May 2024 07:31:15 +0000 (07:31 +0000)] 
Merge "improve pep-695 inference including Enum support" into rel_2_0

15 months agoMerge "ensure result_map objects collection is non-empty" into rel_2_0
Michael Bayer [Thu, 2 May 2024 22:55:01 +0000 (22:55 +0000)] 
Merge "ensure result_map objects collection is non-empty" into rel_2_0

15 months agoimprove pep-695 inference including Enum support
Alc-Alc [Thu, 25 Apr 2024 19:42:34 +0000 (15:42 -0400)] 
improve pep-695 inference including Enum support

Fixed issue in ORM Annotated Declarative where typing issue where literals
defined using :pep:`695` type aliases would not work with inference of
:class:`.Enum` datatypes. Pull request courtesy of Alc-Alc.

Fixes: #11305
Closes: #11313
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11313
Pull-request-sha: 090f0d865c4129cffffbce6a6ce3db9b91602460

Change-Id: Iac63302ad74fd7018a34a50c80ec3aeb87dc94a4
(cherry picked from commit ce26cfa5d5253345a5f962359e5c742ea039c211)

15 months agoMerge "Improve typing to the count function." into rel_2_0
Michael Bayer [Thu, 2 May 2024 22:34:53 +0000 (22:34 +0000)] 
Merge "Improve typing to the count function." into rel_2_0

15 months agodisable col deduping inside of Bundle
Mike Bayer [Thu, 2 May 2024 15:45:31 +0000 (11:45 -0400)] 
disable col deduping inside of Bundle

Fixed issue where attribute key names in :class:`_orm.Bundle` would not be
correct when using ORM enabled :class:`_sql.select` vs.
:class:`_orm.Query`, when the statement contained duplicate column names.

Fixed issue in typing for :class:`_orm.Bundle` where creating a nested
:class:`_orm.Bundle` structure were not allowed.

Fixes: #11347
Change-Id: I24b37c99f83068c668736caaaa06e69a6801ff50
(cherry picked from commit 7d6d7ef73a680d1502ac675b9ae53a6c335b723e)

15 months agoMerge "Ignore all dunders when checking attributes in `sqlalchemy.util.langhelpers...
Michael Bayer [Wed, 1 May 2024 15:51:37 +0000 (15:51 +0000)] 
Merge "Ignore all dunders when checking attributes in `sqlalchemy.util.langhelpers.TypingOnly`" into rel_2_0

15 months agoensure result_map objects collection is non-empty
Mike Bayer [Tue, 30 Apr 2024 19:41:04 +0000 (15:41 -0400)] 
ensure result_map objects collection is non-empty

Fixed issue in cursor handling which affected handling of duplicate
:class:`_sql.Column` or similar objcts in the columns clause of
:func:`_sql.select`, both in combination with arbitary :func:`_sql.text()`
clauses in the SELECT list, as well as when attempting to retrieve
:meth:`_engine.Result.mappings` for the object, which would lead to an
internal error.

Fixes: #11306
Change-Id: I418073b2fdba86b2121b6d00eaa40b1805b69bb8
(cherry picked from commit fbb7172c69402d5f0776edc96d1c23a7cfabd3d0)

15 months agoMerge "only consider column / relationship attrs for subclass IN" into rel_2_0
Michael Bayer [Tue, 30 Apr 2024 16:16:00 +0000 (16:16 +0000)] 
Merge "only consider column / relationship attrs for subclass IN" into rel_2_0

15 months agoMerge "Fix issue in bulk_save_objects" into rel_2_0
Michael Bayer [Tue, 30 Apr 2024 16:14:49 +0000 (16:14 +0000)] 
Merge "Fix issue in bulk_save_objects" into rel_2_0

15 months agoIgnore all dunders when checking attributes in `sqlalchemy.util.langhelpers.TypingOnly`
Edgar Ramírez-Mondragón [Tue, 30 Apr 2024 01:53:07 +0000 (21:53 -0400)] 
Ignore all dunders when checking attributes in `sqlalchemy.util.langhelpers.TypingOnly`

Fixed an internal class that was testing for unexpected attributes to work
correctly under upcoming Python 3.13.   Pull request courtesy Edgar
Ramírez-Mondragón.

Fixes: #11334
Closes: #11335
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11335
Pull-request-sha: babd703e6e34b93722a54c3adf13aa792d3a03b3

Change-Id: Ia2e7392c9403e25266c7d30b987b577f49d008c0
(cherry picked from commit eb118e23a29a29469edb4c1927250f4b726de68e)

15 months agoset unique=False on indexes
Mike Bayer [Tue, 30 Apr 2024 13:28:07 +0000 (09:28 -0400)] 
set unique=False on indexes

References: https://github.com/sqlalchemy/sqlalchemy/discussions/11339
Change-Id: Ia4adc2d5911926fdd1896cc561d511bdd647732d
(cherry picked from commit f00f34437d37f4776b323317432167ad5fe8413b)

15 months agoFix issue in bulk_save_objects
Federico Caselli [Sun, 28 Apr 2024 10:01:05 +0000 (12:01 +0200)] 
Fix issue in bulk_save_objects

Fixes issue in :meth:`_orm.Session.bulk_save_objects()` where it would write a
wrong identity key when using ``return_defaults=True``.
The wrong identity key could lead to an index error when entities are then pickled.

Fixes: #11332
Change-Id: I8d095392ad03e8d3408e477476cd5de8a5bca2c0
(cherry picked from commit ade4bdfb0406fadff566aa8d39abe6aa29af521f)

15 months agoMerge "improve fetchmany performance when using deque" into rel_2_0
Michael Bayer [Mon, 29 Apr 2024 14:09:00 +0000 (14:09 +0000)] 
Merge "improve fetchmany performance when using deque" into rel_2_0

15 months agoonly consider column / relationship attrs for subclass IN
Mike Bayer [Sun, 28 Apr 2024 17:39:08 +0000 (13:39 -0400)] 
only consider column / relationship attrs for subclass IN

Fixed issue in  :func:`_orm.selectin_polymorhpic` loader option where
attributes defined with :func:`_orm.composite` on a superclass would cause
an internal exception on load.

Define the prop for :class:`.PropRegistry` as a
:class:`.StrategizedProperty`; we dont make path registries for
descriptor props like synonyms, composites, etc.

Fixes: #11291
Change-Id: I6f16844d2483dc86ab402b0b8b1f09561498aa1f
(cherry picked from commit f4a0ff730cc753d4d6f947959c6551fd10d7d699)

15 months agoensure intermediary mappers emit subclass IN
Mike Bayer [Sat, 27 Apr 2024 04:31:07 +0000 (00:31 -0400)] 
ensure intermediary mappers emit subclass IN

Fixed issue in :func:`_orm.selectin_polymorhpic` loader option where the
SELECT emitted would only accommodate for the child-most class among the
result rows that were returned, leading intermediary-class attributes to be
unloaded if there were no concrete instances of that intermediary-class
present in the result.   This issue only presented itself for multi-level
inheritance hierarchies.

Fixes: #11327
Change-Id: Iec88cc517613d031221a1c035c4cfb46db0154be
(cherry picked from commit 37c598a41efd2609622b1ca6ee698dbe0ab5ac8b)

15 months agoimprove fetchmany performance when using deque
Federico Caselli [Sat, 27 Apr 2024 11:06:03 +0000 (13:06 +0200)] 
improve fetchmany performance when using deque

Change-Id: Id30e770eb44eafd3e939c4076b639e8e6962c54b
(cherry picked from commit 319304e7c9e5c6c2e42513b81f85aa6b238495b5)

15 months agoFixing ci errors
Federico Caselli [Sat, 27 Apr 2024 08:48:47 +0000 (10:48 +0200)] 
Fixing ci errors

Change-Id: Ia1e3a8748a36dd3fa013707eae5ee4f97013d71b
(cherry picked from commit d85289b35ee6c2683eef378f1ea2fdea7f401ed9)

15 months agoMerge "consider propagate_to_loaders at application time" into rel_2_0
Michael Bayer [Sat, 27 Apr 2024 04:33:52 +0000 (04:33 +0000)] 
Merge "consider propagate_to_loaders at application time" into rel_2_0

15 months agoMerge "Add missing overload to __add__" into rel_2_0
Federico Caselli [Fri, 26 Apr 2024 20:35:15 +0000 (20:35 +0000)] 
Merge "Add missing overload to __add__" into rel_2_0

15 months agoFix typo in sqlalchemy.event.api (#11325)
Felix Zenk [Fri, 26 Apr 2024 19:25:19 +0000 (21:25 +0200)] 
Fix typo in sqlalchemy.event.api (#11325)

(cherry picked from commit f0ed44e89ea83dc2f994105dcd0c471bcb54d608)

15 months agoAdd missing overload to __add__
Yossi Rozantsev [Wed, 24 Apr 2024 20:15:30 +0000 (16:15 -0400)] 
Add missing overload to __add__

Add a missing `@overload` to the `__add__` operator.

### Description
The `__add__` function is missing an overload that handles the rest of the cases, similar to the one that `__sub__` has a few lines later in the same file.

This fix is taken from https://github.com/microsoft/pyright/issues/7743

### Checklist
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: #11307
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11307
Pull-request-sha: 961d87403a5f985fbd17e07bae490e8e97475158

Change-Id: I27784f79e8d4f8b7f09b17060186916c78cba0a3
(cherry picked from commit 18b5b8a5b4d40b8ed8695a4027cedaaafa04cff4)

15 months agoImprove typing to the count function.
Federico Caselli [Wed, 24 Apr 2024 19:47:01 +0000 (21:47 +0200)] 
Improve typing to the count function.

Improve typing to allow `'*'` and 1 in the count function.

Fixes: #11316
Change-Id: Iaafdb779b6baa70504154099f0b9554c612a9ffa
(cherry picked from commit 55fb04f10c0aeee7ace984dbe66642a1286594de)

15 months agoMerge "Fix typing to support mypy 1.10" into rel_2_0
Federico Caselli [Thu, 25 Apr 2024 19:42:53 +0000 (19:42 +0000)] 
Merge "Fix typing to support mypy 1.10" into rel_2_0

15 months agoAdd Databricks to external dialect list
Gord Thompson [Thu, 25 Apr 2024 15:14:53 +0000 (09:14 -0600)] 
Add Databricks to external dialect list

Change-Id: I155e274c6baaeb044f7fda76ba74a63ab9e8e4e3
(cherry picked from commit d1cda3482aeb4b7edbcd564dc3523b974848a02c)

15 months agoFix typing to support mypy 1.10
Federico Caselli [Wed, 24 Apr 2024 20:30:21 +0000 (22:30 +0200)] 
Fix typing to support mypy 1.10

Change-Id: I77c0a04331a99c7be77c174721431a5601475dc3
(cherry picked from commit 859dda8f0b2874fcf7f080d15411336047b89a64)

15 months agoAdd Databend and Greenplum dialects (#11248)
Pat Buxton [Wed, 24 Apr 2024 20:48:02 +0000 (21:48 +0100)] 
Add Databend and Greenplum dialects (#11248)

(cherry picked from commit 7adc7404acc691698e30c362a8ec03af2bd426fd)

15 months agoChanged some `declared_attr` code examples in the docs to return `mapped_column`...
gmanny [Wed, 24 Apr 2024 20:41:34 +0000 (22:41 +0200)] 
Changed some `declared_attr` code examples in the docs to return `mapped_column` to indicate that it's possible. (#11302)

(cherry picked from commit 81c2503173fc674baa579a355e63e020969618af)

15 months agoconsider propagate_to_loaders at application time
Mike Bayer [Thu, 18 Apr 2024 22:17:21 +0000 (18:17 -0400)] 
consider propagate_to_loaders at application time

Fixed regression from 1.4 where using :func:`_orm.defaultload` in
conjunction with a non-propagating loader like :func:`_orm.contains_eager`
would nonetheless propagate the :func:`_orm.contains_eager` to a lazy load
operation, causing incorrect queries as this option is only intended to
come from an original load.

Fixes: #11292
Change-Id: I79928afa108970b523f2166c3190f7952eca73ed
(cherry picked from commit 80399cefa1b16a8548ba0c997a1eda94b8e9db01)

15 months agoImprove docs formatting on automap, fix missing import
Federico Caselli [Wed, 17 Apr 2024 20:17:25 +0000 (22:17 +0200)] 
Improve docs formatting on automap, fix missing import

Fixes: #11273
Change-Id: I872dcc0c2cf5093034e1590533b2e0d26602df7f
References: #11267
(cherry picked from commit 82803016b5fcbc3225af87a43768dbea2be87582)

15 months agoFix missing pythonpath in test that use subprocess
Federico Caselli [Mon, 15 Apr 2024 19:52:38 +0000 (21:52 +0200)] 
Fix missing pythonpath in test that use subprocess

Ensure the ``PYTHONPATH`` variable is properly initialized when
using ``subprocess.run`` in the tests.

Fixes: #11268
Change-Id: Ie2db656364931b3be9033dcaaf7a7c56b383ecca
(cherry picked from commit b5cf61c504e6ff7cdceeb0ca376eb47a97b9da5a)

15 months agoMerge "typing: annotate Exists.select() to return Select[bool]" into rel_2_0
Michael Bayer [Fri, 12 Apr 2024 15:49:23 +0000 (15:49 +0000)] 
Merge "typing: annotate Exists.select() to return Select[bool]" into rel_2_0

15 months agoDocument how to configure the cursor_factory on psycopg
Federico Caselli [Thu, 11 Apr 2024 19:24:54 +0000 (21:24 +0200)] 
Document how to configure the cursor_factory on psycopg

Change-Id: I117a0600c31dde721c99891caaa43937458e78d9
Refereinces: #8978
(cherry picked from commit 497c4a2c22be2e5c2319acf56e11d3037a552064)

15 months agoMerge "Fix typing issue in `MetaData.reflect()` with asyncio." into rel_2_0
Federico Caselli [Wed, 10 Apr 2024 20:42:14 +0000 (20:42 +0000)] 
Merge "Fix typing issue in `MetaData.reflect()` with asyncio." into rel_2_0

15 months agoMerge "Highlite composide mode that's more type checker friently" into rel_2_0
Federico Caselli [Wed, 10 Apr 2024 19:03:50 +0000 (19:03 +0000)] 
Merge "Highlite composide mode that's more type checker friently" into rel_2_0

15 months agoFix typing issue in `MetaData.reflect()` with asyncio.
Francisco Del Roio [Fri, 5 Apr 2024 16:05:51 +0000 (12:05 -0400)] 
Fix typing issue in `MetaData.reflect()` with asyncio.

Fixed typing regression caused by PR :ticket:`11055` in version 2.0.29 that
attempted to add ``ParamSpec`` to the asyncio ``run_sync()`` methods, where
using :meth:`_asyncio.AsyncConnection.run_sync` with
meth:`_schema.MetaData.reflect` would fail on mypy due to a bug.
See https://github.com/python/mypy/issues/17093 for details.
Pull request courtesy of Francisco R. Del Roio

Fixes: #11200
Closes: #11201
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11201
Pull-request-sha: 49e10e0d2a7bbadf471212033e25b7616b99c092

Change-Id: Ie2ebaebd1bc1ee1b865b78561cb6cb8937e85eca
(cherry picked from commit 40fc02d93f3f8b4d9ae2f7bf987f5f965a761dd4)

15 months agoimprove distinct() docs
Mike Bayer [Wed, 10 Apr 2024 14:28:28 +0000 (10:28 -0400)] 
improve distinct() docs

differentiate more clearly between distinct() and select().distinct().

Change-Id: Id5eae749393e5898ae501b2462ec4c2c54262e2f
(cherry picked from commit da639af16f77118bc17bbf5cf78fe41dd1818168)

15 months agoUpdate links from initd.org to psycopg.org (#11244)
Stefan Wojcik [Mon, 8 Apr 2024 19:23:19 +0000 (15:23 -0400)] 
Update links from initd.org to psycopg.org (#11244)

(cherry picked from commit ac7d70dea89dfaf8e061bc8dd03a1ed7825069fc)

16 months agoHighlite composide mode that's more type checker friently
Federico Caselli [Thu, 4 Apr 2024 18:56:39 +0000 (20:56 +0200)] 
Highlite composide mode that's more type checker friently

Change-Id: I9c7d79f31ab5e7a7f63aca4ba42c93f346acdefe
References: #11232
(cherry picked from commit 585a582db0c3a3271659bd48e13abe42eb67ac13)

16 months agotyping: annotate Exists.select() to return Select[bool]
wouter bolsterlee [Thu, 4 Apr 2024 18:15:07 +0000 (14:15 -0400)] 
typing: annotate Exists.select() to return Select[bool]

Fixes: #11231
A query of the form:

``` sql
SELECT EXISTS (
    SELECT 1
    FROM ...
    WHERE ...
)
```

… returns a boolean.

Closes: #11233
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11233
Pull-request-sha: 1bec1cac731eb42e097948f84ae3d0ef133f8a9a

Change-Id: I407a3bd9ed21a180c6c3ff02250aa0a9fbe502d7
(cherry picked from commit ceb9e021cd5df3aa7f3beed2c9564d5f182bf8b6)

16 months agoset up is_from_statement and others for FromStatement
Mike Bayer [Mon, 1 Apr 2024 21:54:22 +0000 (17:54 -0400)] 
set up is_from_statement and others for FromStatement

Added new attribute :attr:`_orm.ORMExecuteState.is_from_statement`, to
detect statements of the form ``select().from_statement()``, and also
enhanced ``FromStatement`` to set :attr:`_orm.ORMExecuteState.is_select`,
:attr:`_orm.ORMExecuteState.is_insert`,
:attr:`_orm.ORMExecuteState.is_update`, and
:attr:`_orm.ORMExecuteState.is_delete` according to the element that is
sent to the :meth:`_sql.Select.from_statement` method itself.

Fixes: #11220
Change-Id: I3bf9e7e22fa2955d772b3b6ad636ed93a60916ae
(cherry picked from commit d3222a31b8df97a454b37a32881dd484a06e5742)

16 months agonew flake8-builtins adds a code we dont want
Mike Bayer [Mon, 1 Apr 2024 23:28:01 +0000 (19:28 -0400)] 
new flake8-builtins adds a code we dont want

A005 "he module is shadowing a Python builtin module "

Change-Id: I9c7464e8f0c32df76d4c455e502b8bc7f94aa038
(cherry picked from commit c3f8bd1c27fd5e376e88533542aa6fd669c58067)

16 months agouse a full ConnectionCharacteristic for logging_token
Mike Bayer [Thu, 28 Mar 2024 13:59:44 +0000 (09:59 -0400)] 
use a full ConnectionCharacteristic for logging_token

Fixed issue in the
:paramref:`_engine.Connection.execution_options.logging_token` option,
where changing the value of ``logging_token`` on a connection that has
already logged messages would not be updated to reflect the new logging
token.  This in particular prevented the use of
:meth:`_orm.Session.connection` to change the option on the connection,
since the BEGIN logging message would already have been emitted.

Fixes: #11210
Change-Id: I0ddade3778215259a6eacde3a67e09d30bc3257b
(cherry picked from commit a124a593c86325389a92903d2b61f40c34f6d6e2)

16 months agoremove restore_asyncio hack
Mike Bayer [Sun, 24 Mar 2024 15:43:33 +0000 (11:43 -0400)] 
remove restore_asyncio hack

we have backported the asnycio.Runner from 2.1 so we dont
need this hack anymore; it fails if greenlet is not installed

Change-Id: I9e2ce09f9987ba5a4a78881475d85b9fa24e5bb4

16 months agoVersion 2.0.30 placeholder
Mike Bayer [Sat, 23 Mar 2024 21:53:46 +0000 (17:53 -0400)] 
Version 2.0.30 placeholder

16 months ago- 2.0.29 rel_2_0_29
Mike Bayer [Sat, 23 Mar 2024 21:46:25 +0000 (17:46 -0400)] 
- 2.0.29

16 months agotyping fix
Mike Bayer [Sat, 23 Mar 2024 20:59:40 +0000 (16:59 -0400)] 
typing fix

the most recent greenlet/asyncio commit introduced a typing error
that only comes up under python3.10 due to the non-presence of
asyncio.Runner in that version.  do an intricate dance here along with
another python-version-specific thing observed around the greenlet
import.

Change-Id: I1b220ab8ea633cdf43ad7e8abe826f758858b62a

16 months agouse asyncio.Runner for tests
Mike Bayer [Sat, 23 Mar 2024 17:02:46 +0000 (13:02 -0400)] 
use asyncio.Runner for tests

Backported to SQLAlchemy 2.0 an improvement to the test suite with regards
to how asyncio related tests are run, now using the newer Python 3.11
``asyncio.Runner`` or a backported equivalent, rather than relying on the
previous implementation based on ``asyncio.get_running_loop()``.  This
should hopefully prevent issues with large suite runs on CPU loaded
hardware where the event loop seems to become corrupted, leading to
cascading failures.

Fixes: #11187
Change-Id: I867b2478b9ba3a152fbfef380650eb987527ba46

16 months agochangelog fixes
Mike Bayer [Sat, 23 Mar 2024 14:55:55 +0000 (10:55 -0400)] 
changelog fixes

Change-Id: I1e1b752660d2186647c15f2b19e8eece720f29cb
(cherry picked from commit 438f09c82a295343e4211df7a31582e829ecde35)

16 months agoMerge "Add pg DOMAIN type reflection" into rel_2_0
Michael Bayer [Sat, 23 Mar 2024 05:20:55 +0000 (05:20 +0000)] 
Merge "Add pg DOMAIN type reflection" into rel_2_0

16 months agoMerge "subqueryload invokes compile() on _OverrideBinds - do robust replace of bp...
Michael Bayer [Fri, 22 Mar 2024 14:34:10 +0000 (14:34 +0000)] 
Merge "subqueryload invokes compile() on _OverrideBinds - do robust replace of bp" into rel_2_0

16 months agoMerge "use a private return class for the "catch all" relationship" into rel_2_0
Michael Bayer [Fri, 22 Mar 2024 13:30:52 +0000 (13:30 +0000)] 
Merge "use a private return class for the "catch all" relationship" into rel_2_0

16 months agoAdd pg DOMAIN type reflection
Thomas Stephenson [Wed, 21 Feb 2024 20:17:01 +0000 (15:17 -0500)] 
Add pg DOMAIN type reflection

The PostgreSQL dialect now returns :class:`_postgresql.DOMAIN` instances
when reflecting a column that has a domain as type.
Previously the domain data type was returned instead.
As part of this change, the domain reflection was improved to also
return the collation of the text types.

Fixes: #10693
Closes: #10729
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10729
Pull-request-sha: adac164d191138265ecd64a28be91254a53a9c25

Change-Id: I8730840de2e7e9649067191430eefa086bcf5e7b
(cherry picked from commit 0b6a54811d9cf4943ba2ae4b5a0eaa718b1e848e)

16 months agoMerge "assign variant mapping on adapt()" into rel_2_0
Michael Bayer [Fri, 22 Mar 2024 13:23:25 +0000 (13:23 +0000)] 
Merge "assign variant mapping on adapt()" into rel_2_0

16 months agoMerge "A scalar subquery that returns bool is now correctly typed" into rel_2_0
Michael Bayer [Fri, 22 Mar 2024 13:22:49 +0000 (13:22 +0000)] 
Merge "A scalar subquery that returns bool is now correctly typed" into rel_2_0

16 months agosubqueryload invokes compile() on _OverrideBinds - do robust replace of bp
Mike Bayer [Tue, 19 Mar 2024 17:35:35 +0000 (13:35 -0400)] 
subqueryload invokes compile() on _OverrideBinds - do robust replace of bp

Fixed regression from version 2.0.28 caused by the fix for :ticket:`11085`
where the newer method of adjusting post-cache bound parameter values would
interefere with the implementation for the :func:`_orm.subqueryload` loader
option, which has some more legacy patterns in use internally, when
the additional loader criteria feature were used with this loader option.

Fixes: #11173
Change-Id: I88982fbcc809d516eb7c46a00fb807aab9c3a98e
(cherry picked from commit b6f63a57ed878c1e157ecf86cb35d8b15cd7ea3b)

16 months agoensure ARRAY.__init__ documents before Comparator
Mike Bayer [Thu, 21 Mar 2024 06:13:22 +0000 (02:13 -0400)] 
ensure ARRAY.__init__ documents before Comparator

also add note for zero_indexes to generic and PG ARRAY
types

References: https://github.com/sqlalchemy/sqlalchemy/discussions/11100
Change-Id: I2087da695787a930f325cfb2fa4156d19c8e8f31
(cherry picked from commit 7c70ab8c6b7b9ce1c566862c4ca0438e0b0e9131)

16 months agoA scalar subquery that returns bool is now correctly typed
Federico Caselli [Wed, 20 Mar 2024 21:18:35 +0000 (22:18 +0100)] 
A scalar subquery that returns bool is now correctly typed

Fixes: #10937
Change-Id: Iba4986be14fefd4210b727ddb7ae7e9291ab7f7f
(cherry picked from commit bf7289f9d4218275d32ce7cfcb24a8da3475d95d)

16 months agouse a private return class for the "catch all" relationship
Mike Bayer [Thu, 9 Nov 2023 15:27:19 +0000 (10:27 -0500)] 
use a private return class for the "catch all" relationship

Fixed Declarative issue where typing a relationship using
:class:`_orm.Relationship` rather than :class:`_orm.Mapped` would
inadvertently pull in the "dynamic" relationship loader strategy for that
attribute.

Fixes: #10611
Change-Id: Ie4421050b583827fdf96c27ae9d7fe7ca596e77e
(cherry picked from commit 7cfb940b1a9392f6e3784aff8f487c37ebcd588b)

16 months agoassign variant mapping on adapt()
Mike Bayer [Wed, 20 Mar 2024 14:23:41 +0000 (10:23 -0400)] 
assign variant mapping on adapt()

Fixed regression from the 1.4 series where the refactor of the
:meth:`_types.TypeEngine.with_variant` method introduced at
:ref:`change_6980` failed to accommodate for the ``.copy()`` method, which
will lose the variant mappings that are set up. This becomes an issue for
the very specific case of a "schema" type, which includes types such as
:class:`.Enum` and :class:`.ARRAY`, when they are then used in the context
of an ORM Declarative mapping with mixins where copying of types comes into
play.  The variant mapping is now copied as well.

Fixes: #11176
Change-Id: Icf1a2752f60fce863c87ead8b0fe298b0f3d3766
(cherry picked from commit 29a428955a904e235e1b85e928cbe89155aeca82)