]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
13 months agodocs: simplify getting a connection & committing changes 11542/head
lonkeknol [Thu, 27 Jun 2024 17:15:56 +0000 (19:15 +0200)] 
docs: simplify getting a connection & committing changes

13 months agoDocs: simplify language use for "Working with Transactions and the DBAPI"
lonkeknol [Thu, 27 Jun 2024 13:03:30 +0000 (09:03 -0400)] 
Docs: simplify language use for "Working with Transactions and the DBAPI"

### Description
This is my first pull request to sqlalchemy. It changes the writing style of two paragraphs in the unified tutorial [here](https://docs.sqlalchemy.org/en/20/tutorial/dbapi_transactions.html#working-with-transactions-and-the-dbapi). My goals were to.
1. Make them easier to read
2. Not change the meaning of the text.
3. Get feedback on whether this type of contribution is considered useful for sqlalchemy.

If this is a useful type of contribution, it might be good to discuss some general guidelines for me to adhere to as I continue. For instance:
- Prefer using present simple tense
- Remove superfluous words where possible
- Keep the pull requests to one or two h2 sections at a time, to make the review easier

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

I'm curious to hear what you all think. **Have a nice day!**

Closes: #11541
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11541
Pull-request-sha: 3179690e6a5b47de99a4486a7a15cffbfacd380b

Change-Id: I9b47f6ce4fd00c44c4b0e19957acf250f5e46d2f

13 months agoadd additional test cases re: #11371
Mike Bayer [Wed, 26 Jun 2024 16:13:28 +0000 (12:13 -0400)] 
add additional test cases re: #11371

Just want to make sure aliased() and with_polymorphic() still
work in the of_type() context here, since that's likely why we
had Any for this parameter in the first place

Change-Id: I0a2c4445bc3b91039b3446d31b4a02db28feaee7

13 months agoMerge "set type of type_of to be same as input argument" into main
Michael Bayer [Wed, 26 Jun 2024 16:09:57 +0000 (16:09 +0000)] 
Merge "set type of type_of to be same as input argument" into main

13 months agoMerge "Handle "SSL SYSCALL error: Success" in psycopg2" into main
Michael Bayer [Wed, 26 Jun 2024 16:09:00 +0000 (16:09 +0000)] 
Merge "Handle "SSL SYSCALL error: Success" in psycopg2" into main

13 months agoHandle "SSL SYSCALL error: Success" in psycopg2
David H. Irving [Sun, 23 Jun 2024 09:37:24 +0000 (05:37 -0400)] 
Handle "SSL SYSCALL error: Success" in psycopg2

Added "SSL SYSCALL error: Success" to the list of exceptions
that are considered a "disconnect" in psycopg2.

Fixes: #11522
Closes: #11523
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11523
Pull-request-sha: 63ad54e49dc3daa459caa29da8cffcb3e47a3f8c

Change-Id: I0db49d5c4db418a8e634f5370c76b99aaa3d3af6

13 months agoset type of type_of to be same as input argument
Wouter Kayser [Sun, 23 Jun 2024 10:18:05 +0000 (06:18 -0400)] 
set type of type_of to be same as input argument

Fixes: #11371
Fixes the of_type method so that it does not return a class with unset generic.
See the original issue for a more detailed explanation.

Closes: #11416
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11416
Pull-request-sha: ed8d0edebb6b84b9dcffcf24c52f113c37e7fedd

Change-Id: I35637491d6d9c573825f6d13299712626dd521c5

13 months agoMerge "use a new ClauseElement for Over.range_ / Over.rows" into main
Michael Bayer [Tue, 25 Jun 2024 13:57:14 +0000 (13:57 +0000)] 
Merge "use a new ClauseElement for Over.range_ / Over.rows" into main

13 months agouse a new ClauseElement for Over.range_ / Over.rows
Mike Bayer [Sun, 23 Jun 2024 19:40:31 +0000 (15:40 -0400)] 
use a new ClauseElement for Over.range_ / Over.rows

Enhanced the caching structure of the :paramref:`.over.rows` and
:paramref:`.over.range` so that different numerical values for the rows /
range fields are cached on the same cache key, to the extent that the
underlying SQL does not actually change (i.e. "unbounded", "current row",
negative/positive status will still change the cache key).  This prevents
the use of many different numerical range/rows value for a query that is
otherwise identical from filling up the SQL cache.

Note that the semi-private compiler method ``_format_frame_clause()``
is removed by this fix, replaced with a new method
``visit_frame_clause()``.  Third party dialects which may have referred
to this method will need to change the name and revise the approach to
rendering the correct SQL for that dialect.

This patch introduces a new ClauseElement called _FrameClause which
stores the integer range values separately and within cache-compatible
BindParameter objects from the "type" which
can be unbounded, current, preceding, or following, represented by
a _FrameClauseType enum.    The negative
sign is also stripped from the integer and represented within the
_FrameClauseType.  Tests from #11514 are adapted to include
a test for SQL Server's "literal_execute" flag taking effect so
that literal numeric values aren't stored in the cache.

Fixes: #11515
Change-Id: I8aad368ffef9f06cb5c3f8c4e971fadef029ffd5

13 months agocreate JoinedDispatcher subclasses up front
Mike Bayer [Mon, 24 Jun 2024 19:07:41 +0000 (15:07 -0400)] 
create JoinedDispatcher subclasses up front

Fixed additional issues in the event system triggered by unpickling of a
:class:`.Enum` datatype, continuing from :ticket:`11365` and
:ticket:`11360`,  where dynamically generated elements of the event
structure would not be present when unpickling in a new process.

Fixes: #11530
Change-Id: Ie1f2b3453d4891051f8719f6d3f6703302d5a86e

13 months agoMerge "use literal execute for SQL Server frame parameters" into main
Michael Bayer [Sun, 23 Jun 2024 18:17:05 +0000 (18:17 +0000)] 
Merge "use literal execute for SQL Server frame parameters" into main

13 months agofix default label style doc
Mike Bayer [Sun, 23 Jun 2024 14:18:47 +0000 (10:18 -0400)] 
fix default label style doc

Change-Id: I793f7b62c6c0b551ab1957cabcff685885b6e51c

13 months agoDocumentation: Update package name for CrateDB dialect (#11503)
Andreas Motl [Sun, 23 Jun 2024 10:14:15 +0000 (12:14 +0200)] 
Documentation: Update package name for CrateDB dialect (#11503)

The CrateDB SQLAlchemy dialect needs more love, so it was separated from
the DBAPI HTTP driver.

The new canonical package for the SQLAlchemy CrateDB dialect on PyPI is:

  https://pypi.org/project/sqlalchemy-cratedb/

13 months agoBump pypa/cibuildwheel from 2.19.0 to 2.19.1 (#11491)
dependabot[bot] [Sun, 23 Jun 2024 10:08:31 +0000 (12:08 +0200)] 
Bump pypa/cibuildwheel from 2.19.0 to 2.19.1 (#11491)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.19.0 to 2.19.1.
- [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.19.0...v2.19.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
13 months agouse literal execute for SQL Server frame parameters
Mike Bayer [Wed, 19 Jun 2024 15:03:25 +0000 (11:03 -0400)] 
use literal execute for SQL Server frame parameters

Fixed issue where SQL Server drivers don't support bound parameters when
rendering the "frame specification" for a window function, e.g. "ROWS
BETWEEN", etc.

Fixes: #11514
Change-Id: I0664f4076a2a8266434a4670949b8b44cd261f44

13 months agopin setuptools below 69.3 and prepare for "build" for releases
Mike Bayer [Wed, 19 Jun 2024 15:44:54 +0000 (11:44 -0400)] 
pin setuptools below 69.3 and prepare for "build" for releases

Change-Id: Ib70446cc3c7d7d8acb264ffa2237a0c7aac5a0f5

13 months agocherry-pick changelog update for 2.0.32
Mike Bayer [Tue, 18 Jun 2024 21:39:11 +0000 (17:39 -0400)] 
cherry-pick changelog update for 2.0.32

13 months agocherry-pick changelog from 2.0.31
Mike Bayer [Tue, 18 Jun 2024 21:39:11 +0000 (17:39 -0400)] 
cherry-pick changelog from 2.0.31

13 months agoMerge "restore declared_attr consumption for __table__" into main
Michael Bayer [Tue, 18 Jun 2024 16:31:56 +0000 (16:31 +0000)] 
Merge "restore declared_attr consumption for __table__" into main

13 months agoMerge "Improve the documentation of json.as method" into main
Michael Bayer [Tue, 18 Jun 2024 16:30:11 +0000 (16:30 +0000)] 
Merge "Improve the documentation of json.as method" into main

13 months agoCorrect 'Session.is_modified' method documentation
Roman Druzhkov [Sun, 16 Jun 2024 18:48:30 +0000 (14:48 -0400)] 
Correct 'Session.is_modified' method documentation

Correct 'Session.is_modified' method documentation.

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

### Description
Correct documentation according to discussion: https://github.com/sqlalchemy/sqlalchemy/discussions/11481#discussioncomment-9759171

### 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: #11501
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11501
Pull-request-sha: 16e949af544b4a1a94ccc5660e164fd2bca8be78

Change-Id: Ia8be0e3865190f0667de006c3006ecf646ef8422
(cherry picked from commit 30492d665ed7edc474d151f0854ed4837dcafaed)

13 months agorestore declared_attr consumption for __table__
Mike Bayer [Tue, 18 Jun 2024 02:45:16 +0000 (22:45 -0400)] 
restore declared_attr consumption for __table__

Fixed bug in ORM Declarative where the ``__table__`` directive could not be
declared as a class function with :func:`_orm.declared_attr` on a
superclass, including an ``__abstract__`` class as well as coming from the
declarative base itself.  This was a regression since 1.4 where this was
working, and there were apparently no tests for this particular use case.

Fixes: #11509
Change-Id: I82ef0f93d00cb7a43b0b1b16ea28f1a9a79eba3b

13 months agoadd greenlet support for py313
Mike Bayer [Sun, 16 Jun 2024 15:26:41 +0000 (11:26 -0400)] 
add greenlet support for py313

based on vstinners patch

Change-Id: I3e852796b49fe51db51c030d03d17cfb6baa7484

13 months agoMerge "open up async greenlet for third parties" into main
Michael Bayer [Thu, 13 Jun 2024 14:20:57 +0000 (14:20 +0000)] 
Merge "open up async greenlet for third parties" into main

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

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

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

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

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

13 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

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

13 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

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

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

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

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

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

14 months agoMerge "Avoid removing + from odbc_connect parameter values" into main
Michael Bayer [Thu, 30 May 2024 17:47:30 +0000 (17:47 +0000)] 
Merge "Avoid removing + from odbc_connect parameter values" into main

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

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

14 months agoImprove the documentation of json.as method
Federico Caselli [Wed, 27 Mar 2024 21:00:00 +0000 (22:00 +0100)] 
Improve the documentation of json.as method

Mention that these method are more like ``type_coerce`` than
``cast``.

Fixes: #11065
Change-Id: Ia5bd4f6d5f48be9557d0504f628202e1e6ddf6d1

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

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

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

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

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

14 months agoMerge "Add ``insert_default`` to ``Column``." into main
Michael Bayer [Wed, 22 May 2024 15:18:27 +0000 (15:18 +0000)] 
Merge "Add ``insert_default`` to ``Column``." into main

14 months agoAdd results to compiled extensions
Federico Caselli [Tue, 28 Nov 2023 21:40:03 +0000 (22:40 +0100)] 
Add results to compiled extensions

Add the ability to compare a saved result with the current run

Change-Id: I0039cc93ed68d5957753ea49c076d934191e6cd0

14 months agoMerge "Some improvements to the cache key generation speed" into main
Michael Bayer [Fri, 17 May 2024 13:39:21 +0000 (13:39 +0000)] 
Merge "Some improvements to the cache key generation speed" into main

14 months agoMerge "Warn in execute when parameter is an empty list" into main
Michael Bayer [Wed, 15 May 2024 15:32:32 +0000 (15:32 +0000)] 
Merge "Warn in execute when parameter is an empty list" into main

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

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

14 months agoSome improvements to the cache key generation speed
Federico Caselli [Thu, 11 Apr 2024 19:39:25 +0000 (21:39 +0200)] 
Some improvements to the cache key generation speed

Optimize anon map performance
Improve bindparam cache key generation

Improvement is about 10%
(Table must be manually constructed by running
`python test/perf/compiled_extensions CacheKey` on main and in
this change while recompiling cython)

                           | change      | main      | change / main |
check_not_caching          | 0.850238500 | 0.8729132 | 0.9740241069  |
parent_table               | 0.380153900 | 0.4201198 | 0.9048702299  |
parent_orm                 | 0.524657600 | 0.575952  | 0.9109398005  |
parent_orm_join            | 0.852317200 | 0.978303  | 0.8712200617  |
many_types                 | 0.298978000 | 0.3166505 | 0.944189256   |
oracle_all_objects_query   | 0.830102500 | 0.940856  | 0.8822843241  |
oracle_table_options_query | 0.787572400 | 0.8663654 | 0.9090533856  |
oracle_column_query        | 1.020074200 | 1.1518336 | 0.8856089977  |
oracle_comment_query       | 1.054886600 | 1.1857846 | 0.8896106426  |
oracle_index_query         | 0.932308800 | 1.0719409 | 0.869738994   |
oracle_constraint_query    | 1.204755500 | 1.3571617 | 0.8877022539  |
pg_has_table_query         | 0.713250000 | 0.8550803 | 0.8341321862  |
pg_columns_query           | 1.269068400 | 1.4404266 | 0.8810364929  |
pg_table_oids_query        | 0.787948100 | 0.9132093 | 0.8628340732  |
pg_index_query             | 1.118733900 | 1.2628904 | 0.8858519314  |
pg_constraint_query        | 0.917447700 | 1.0175005 | 0.9016680581  |
pg_foreing_key_query       | 0.980781200 | 1.1213958 | 0.8746075204  |
pg_comment_query           | 0.883384900 | 1.0329165 | 0.8552336031  |
pg_check_constraint_query  | 1.043821200 | 1.229517  | 0.8489684974  |
pg_enum_query              | 0.947796800 | 1.043922  | 0.907919174   |
pg_domain_query            | 1.082338200 | 1.2296575 | 0.880194851   |
> Mean values              | -           | -         | 0.8886518305  |

Change-Id: I1c1432978d954863a3967267d599fbb3a53d5ad5

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

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

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

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

14 months agocherry-pick changelog update for 2.0.31
Mike Bayer [Sun, 5 May 2024 18:04:18 +0000 (14:04 -0400)] 
cherry-pick changelog update for 2.0.31

14 months agocherry-pick changelog from 2.0.30
Mike Bayer [Sun, 5 May 2024 18:04:18 +0000 (14:04 -0400)] 
cherry-pick changelog from 2.0.30

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

Change-Id: I8f3a1d755d03e6c11fa1f783f111977b7ddc22fb

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

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

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

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

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

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

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

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

15 months agoWarn in execute when parameter is an empty list
Carlos Sousa [Mon, 8 Jan 2024 19:50:02 +0000 (14:50 -0500)] 
Warn in execute when parameter is an empty list

An empty sequence passed to any ``execute()`` method now
raised a deprecation warning, since such an executemany
is invalid.
Pull request courtesy of Carlos Sousa.

Fixes: #9647
Closes: #10406
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10406
Pull-request-sha: 087ba2d88d079b361e30e698e251c022b5780a3d

Change-Id: I482e91a047477c3156a3ca806e5c1eefb6224b95

15 months agocorrectly apply _set_binops_check_strict to AssociationProxy
Mike Bayer [Thu, 2 May 2024 23:05:08 +0000 (19:05 -0400)] 
correctly apply _set_binops_check_strict to AssociationProxy

Revised the set "binary" operators for the association proxy ``set()``
interface to correctly raise ``TypeError`` for invalid use of the ``|``,
``&``, ``^``, and ``-`` operators, as well as the in-place mutation
versions of these methods, to match the behavior of standard Python
``set()`` as well as SQLAlchemy ORM's "intstrumented" set implementation.

Fixes: #11349
Change-Id: I02442f8885107d115b7ecfa1ca716835a55d4db3

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

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

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

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

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

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

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

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

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

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

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

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

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

15 months agoMerge "ensure intermediary mappers emit subclass IN" into main
Michael Bayer [Sun, 28 Apr 2024 14:35:06 +0000 (14:35 +0000)] 
Merge "ensure intermediary mappers emit subclass IN" into main

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

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

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

Change-Id: Ia1e3a8748a36dd3fa013707eae5ee4f97013d71b

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

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

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)

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

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

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

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

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)

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)

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