]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
19 months agoFix engine connect example in migration guide (#10757)
Iuri de Silvio [Sun, 17 Dec 2023 17:39:28 +0000 (18:39 +0100)] 
Fix engine connect example in migration guide (#10757)

You can't fetchall after connection was closed.

(cherry picked from commit ca9adf3028095ff28bdef823d6f6cefc12815b3c)

19 months agoMerge "Replace custom URL-encoding method with quote" into rel_2_0
Michael Bayer [Wed, 13 Dec 2023 16:01:27 +0000 (16:01 +0000)] 
Merge "Replace custom URL-encoding method with quote" into rel_2_0

19 months agocopy stack related elements to str compiler
Mike Bayer [Tue, 12 Dec 2023 19:57:38 +0000 (14:57 -0500)] 
copy stack related elements to str compiler

Fixed issue in stringify for SQL elements, where a specific dialect is not
passed,  where a dialect-specific element such as the PostgreSQL "on
conflict do update" construct is encountered and then fails to provide for
a stringify dialect with the appropriate state to render the construct,
leading to internal errors.

Fixed issue where stringifying or compiling a :class:`.CTE` that was
against a DML construct such as an :func:`_sql.insert` construct would fail
to stringify, due to a mis-detection that the statement overall is an
INSERT, leading to internal errors.

Fixes: #10753
Change-Id: I783eca3fc7bbc1794fedd325d58181dbcc7e0b75
(cherry picked from commit 0248efb761bec4bdcea76bc6bbe3c09934f6b527)

19 months agorestore ValueError when greenlet not installed
Mike Bayer [Mon, 11 Dec 2023 15:55:25 +0000 (10:55 -0500)] 
restore ValueError when greenlet not installed

continuing for #10747, add a test asserting we dont get an
endless loop and get a clean ValueError instead when greenlet not
installed and async functions are used.

Fixes: #10747
Change-Id: I54dffe8577025e2ef3a59f5ca9ab7f4362d4d91f
(cherry picked from commit 35a0854cae1e23271963e7781c65495e9c84f872)

19 months agoensure test suite runs w/o greenlet
Mike Bayer [Sat, 9 Dec 2023 15:43:37 +0000 (10:43 -0500)] 
ensure test suite runs w/o greenlet

This is a reopen of #6136 essentially that repaired the
test suite to run without greenlet but now this has regressed.
add a tox target that explicitly uninstalls greenlet, will
add to CI.

This also changes 2.0 in that the full tox target will
omit dbdrivers that require greenlet.

Fixes: #10747
Change-Id: Ia7d786d781e591539a388bfbe17b00a59f0e86d9
(cherry picked from commit 0bd686df43f572cec658c586082f299ab2cd756f)

20 months agofix(attribute_keyed_dict): using Any instead of TypeVar (#10746)
Mehdi GMIRA [Fri, 8 Dec 2023 10:54:11 +0000 (11:54 +0100)] 
fix(attribute_keyed_dict): using Any instead of TypeVar (#10746)

Co-authored-by: Mehdi Gmira <mgmira@wiremind.io>
(cherry picked from commit 86f335c29e9f4d9a8e2b28dd75301f28f5f9f4f1)

20 months agoBump actions/setup-python from 4 to 5 (#10737)
dependabot[bot] [Fri, 8 Dec 2023 09:52:38 +0000 (10:52 +0100)] 
Bump actions/setup-python from 4 to 5 (#10737)

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

20 months agoMerge "Forward `**kw` in `__init_subclass__()` to super" into rel_2_0
Michael Bayer [Thu, 7 Dec 2023 14:37:34 +0000 (14:37 +0000)] 
Merge "Forward `**kw` in `__init_subclass__()` to super" into rel_2_0

20 months agoUpdate `TZDateTime` type decorator example to align with python docs
Kevin Kirsche [Mon, 4 Dec 2023 18:25:24 +0000 (13:25 -0500)] 
Update `TZDateTime` type decorator example to align with python docs

This change updates the `TZDateTime` type decorator to use the timezone awareness checks described in the Python documentation located here:

https://docs.python.org/3/library/datetime.html#determining-if-an-object-is-aware-or-naive

The specific lines state:

> A [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) object `d` is aware if both of the following hold:
>
> `d.tzinfo is not None`
>
> `d.tzinfo.utcoffset(d)` does not return `None`
>
> Otherwise, `d` is naive.

Closes: #10719
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10719
Pull-request-sha: bb30cb3cfe57f326addec21a6cae5f81184c2e74

Change-Id: I1ac51c1ec2820c3f224a79b7af5057fe2b3a55e2
(cherry picked from commit e1477c152c5a1e097399300883fcd6b23a6dfabf)

20 months agoReplace custom URL-encoding method with quote
Mike Bayer [Wed, 6 Dec 2023 19:10:28 +0000 (14:10 -0500)] 
Replace custom URL-encoding method with quote

Fixed URL-encoding of the username and password components of
:class:`.engine.URL` objects when converting them to string using the
:meth:`_engine.URL.render_as_string` method, by using Python standard
library ``urllib.parse.quote`` while allowing for plus signs and spaces to
remain unchanged as supported by SQLAlchemy's non-standard URL parsing,
rather than the legacy home-grown routine from many years ago. Pull request
courtesy of Xavier NUNN.

Fixes: #10662
Closes: #10726
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10726
Pull-request-sha: 82219041b8f73d8c932cc40e87c002b3b853e02e
Change-Id: Iedca4929579d4d26ef8cce083252dcd1e476286b
(cherry picked from commit 4438883c9703affa3f441be9a230a5f751905a05)

20 months agoForward `**kw` in `__init_subclass__()` to super
Michael Oliver [Tue, 5 Dec 2023 22:24:17 +0000 (17:24 -0500)] 
Forward `**kw` in `__init_subclass__()` to super

Modified the ``__init_subclass__()`` method used by
:class:`_orm.MappedAsDataclass`, :class:`_orm.DeclarativeBase`` and
:class:`_orm.DeclarativeBaseNoMeta` to accept arbitrary ``**kw`` and to
propagate them to the ``super()`` call, allowing greater flexibility in
arranging custom superclasses and mixins which make use of
``__init_subclass__()`` keyword arguments.  Pull request courtesy Michael
Oliver.

Fixes: #10732
Closes: #10733
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10733
Pull-request-sha: 7fdeec1f3224f48213c9c9af5f3e7e5d0904dafa

Change-Id: I955a735d4e23502b5a6b22ac093e391b378edc87
(cherry picked from commit ceeaaecd2401d2407b60c22708f58a8ae0898d85)

20 months agoMerge "try to gracefully close even in terminate" into rel_2_0
Michael Bayer [Wed, 6 Dec 2023 15:55:07 +0000 (15:55 +0000)] 
Merge "try to gracefully close even in terminate" into rel_2_0

20 months agoImprove session after_begin even documentation
Federico Caselli [Thu, 30 Nov 2023 21:40:43 +0000 (22:40 +0100)] 
Improve session after_begin even documentation

Change-Id: Ie2a1e6bdf5960208921dc76e372fe51d3b280f1a
References: #10687
(cherry picked from commit 842b3ebb4b9e40ce3f6aa4257bd5e585c42e51d2)

20 months agoDocument limitation in dataclass mapping styles
Federico Caselli [Mon, 4 Dec 2023 20:14:45 +0000 (21:14 +0100)] 
Document limitation in dataclass mapping styles

Document that using default and init=False on a dataclass field mapped
imperatively or using imperative table will not work.

Change-Id: Id2e27e4f7f0cafc60be3f97b7945983360c0a7d2
References: #9879
(cherry picked from commit 06c5c8e955402af6c09b8a3c55cbdee3cd0e0393)

20 months agoSpelling dml.rst (#10730)
Kai [Mon, 4 Dec 2023 18:23:43 +0000 (19:23 +0100)] 
Spelling dml.rst (#10730)

Really a very minor spelling correction.

(cherry picked from commit f43b428d2baf6f6fc01c8e3028743cd96c05986e)

20 months agoNeed to escape # in tox v4
Federico Caselli [Mon, 27 Nov 2023 20:39:31 +0000 (21:39 +0100)] 
Need to escape # in tox v4

See https://tox.wiki/en/latest/upgrading.html#changed-ini-rules

Change-Id: I3022538e3f919f5bc977411042d82c62260645a1
(cherry picked from commit aa7145caa1927d8c70f6c5029c3c04528b86c7b0)

20 months agoNormalize all file headers to have consistent format
Federico Caselli [Thu, 30 Nov 2023 21:16:11 +0000 (22:16 +0100)] 
Normalize all file headers to have consistent format

Change-Id: Idfa5f699280990aed3f6e46225d4202539d9e900

20 months agotry to gracefully close even in terminate
Mike Bayer [Thu, 30 Nov 2023 14:11:25 +0000 (09:11 -0500)] 
try to gracefully close even in terminate

Adjusted the asyncpg dialect such that when the ``terminate()`` method is
used to discard an invalidated connection, the dialect will first attempt
to gracefully close the conneciton using ``.close()`` with a timeout, if
the operation is proceeding within an async event loop context only. This
allows the asyncpg driver to attend to finalizing a ``TimeoutError``
including being able to close a long-running query server side, which
otherwise can keep running after the program has exited.

Fixes: #10717
Change-Id: Iaba0aeb67873a7a2b3981d43f4eb663005057309
(cherry picked from commit e70a0b0a0e52945e5b588b5cffec619a3f3e78a1)

20 months agofreshen up callcounts for py311
Mike Bayer [Tue, 28 Nov 2023 02:35:41 +0000 (21:35 -0500)] 
freshen up callcounts for py311

move the oracle tests to use oracledb (because i dont feel like
installing OCI on my laptops anymore)

Change-Id: I8ca7ceb5083dbf2510ec02dc40f202a8e0eaf3dc
(cherry picked from commit 82690b1cfc1e76e5deb622a9afefbcf3be299962)

20 months agoremove errant print statement
Mike Bayer [Sun, 26 Nov 2023 20:16:08 +0000 (15:16 -0500)] 
remove errant print statement

Change-Id: I9cb1571995f078c359a9c2793670a017effe4be2

20 months agoadd MARS connection for aioodbc
Mike Bayer [Sun, 26 Nov 2023 15:02:47 +0000 (10:02 -0500)] 
add MARS connection for aioodbc

on jenkins main we are getting a lot of connection busy with
other results, which we assume is due to the thread-pool based approach
of aioodbc not being very solid.

MARS is described at:

https://stackoverflow.com/questions/9017264/why-only-some-users-get-the-error-connection-is-busy-with-results-for-another
https://learn.microsoft.com/en-us/sql/relational-databases/native-client/features/using-multiple-active-result-sets-mars?view=sql-server-ver16

not clear why the name of the parameter is different in those two
articles. using a totally made up parameter doesn't raise any error,
so it's not clear if this works at all.

Change-Id: I8e437e9f46c1c070c5102a24d7d82a912e8b5145

20 months agoAdd type annotations for Function.filter
Martijn Pieters [Sat, 18 Nov 2023 21:36:08 +0000 (16:36 -0500)] 
Add type annotations for Function.filter

This includes all methods / properties on the returned FunctionFilter
object.

This contributes towards #6810

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.

Closes: #10643
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10643
Pull-request-sha: 6137b7b995b6ea0bd4e4195c5693d2312fa26639

Change-Id: I2af1af7617d0cd3fd30b262d36ff982464bac011
(cherry picked from commit 52452ec39d18567126673eeef4cf0dd12039043b)

20 months agofully type functions.py
Mike Bayer [Fri, 24 Nov 2023 20:20:31 +0000 (15:20 -0500)] 
fully type functions.py

Completed pep-484 typing for the ``sqlalchemy.sql.functions`` module.
:func:`_sql.select` constructs made against ``func`` elements should now
have filled-in return types.

References: #6810
Change-Id: I5121583c9c5b6f7151f811348c7a281c446cf0b8
(cherry picked from commit 045732a738a10891b85be8e286eab3e5b756a445)

20 months agofully update to flake8 6.1.0
Mike Bayer [Fri, 24 Nov 2023 21:27:03 +0000 (16:27 -0500)] 
fully update to flake8 6.1.0

I updated flake8 in pre-commit a few days ago but forgot to do it in
tox.

this flake seems to be picking inside of f-strings, which black does
not fix, so fix these manually.

Change-Id: I9a641a99e280fbba9d893a6f1f051b5039d5d4eb
(cherry picked from commit 7bc33ca55144d2716b175c733c0d6865572787aa)

20 months agoMerge "backport importlib mypy fix" into rel_2_0
mike bayer [Fri, 24 Nov 2023 20:24:52 +0000 (20:24 +0000)] 
Merge "backport importlib mypy fix" into rel_2_0

20 months agoMerge "Fix pre-ping regression in old PyMySQL versions." into rel_2_0
mike bayer [Fri, 24 Nov 2023 15:43:35 +0000 (15:43 +0000)] 
Merge "Fix pre-ping regression in old PyMySQL versions." into rel_2_0

20 months agobackport importlib mypy fix
Mike Bayer [Fri, 24 Nov 2023 13:55:44 +0000 (08:55 -0500)] 
backport importlib mypy fix

this is the fix that was part of f5f08c28fb, this is otherwise
failing for some environments with mypy 6

Change-Id: Ic8b410c4fa1858c98e9299e062f1ff040c2d3576

20 months agoUpgrade to Oracle Database 23c Free
Gerald Venzl [Thu, 23 Nov 2023 19:42:52 +0000 (14:42 -0500)] 
Upgrade to Oracle Database 23c Free

### Description
This PR updates the unittest ReadMe and `setup.cfg` to use Oracle Database Free, the successor to Oracle Database XE.

### 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.
- [ ] 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: #10658
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10658
Pull-request-sha: 1cfb2d3a7f688a4b887182d2485b7d60f12eb013

Change-Id: Id37f6607572c1fdb12d507cd9336800d4d8b0cf3
(cherry picked from commit 44771ab0c32730d1ecefac21af13f113b1b19726)

20 months agodocs: fix type annotation in Self-Referential Many-to-Many Relationsh…
François Voron [Thu, 23 Nov 2023 15:53:07 +0000 (10:53 -0500)] 
docs: fix type annotation in Self-Referential Many-to-Many Relationsh…

A type annotation was wrong in the [Self-Referential Many-to-Many Relationship](https://docs.sqlalchemy.org/en/20/orm/join_conditions.html#self-referential-many-to-many-relationship) code example.

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

### Description

The type annotation was `right_nodes: Mapped[List["None"]]`. I changed it to `Node` since we refer to the ORM class we're looking at.

### 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: #10686
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10686
Pull-request-sha: 7671898116f1b8850e5d8f3ff0f940450a7c1bf4

Change-Id: Iab1535c3d00747eb8c9e9a17aea50606febedbf9
(cherry picked from commit 7157d16e3ba521c119958a727af51790ebdf3f34)

20 months agoFix pre-ping regression in old PyMySQL versions.
Federico Caselli [Wed, 22 Nov 2023 21:04:03 +0000 (22:04 +0100)] 
Fix pre-ping regression in old PyMySQL versions.

Fixed regression introduced by the fix in ticket :ticket:`10492` when using
pool pre-ping with PyMySQL version older than 1.0.

Fixes: #10650
Change-Id: Ic0744c8b6f91cc39868e31c3bfddb8df20c7dfbb

20 months agoadd local column to dependency rule error message
Jan Vollmer [Wed, 22 Nov 2023 18:16:27 +0000 (13:16 -0500)] 
add local column to dependency rule error message

Improved the error message produced when the unit of work process sets the
value of a primary key column to NULL due to a related object with a
dependency rule on that column being deleted, to include not just the
destination object and column name but also the source column from which
the NULL value is originating.  Pull request courtesy Jan Vollmer.

Fixes: #10668
Closes: #10669
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10669
Pull-request-sha: d7f9952b81394d585e55dad6d6f355aaa54f599e

Change-Id: I210317f8777ff07d9eec674b79f2140523af38d0
(cherry picked from commit 87929a9c55163ebcd7edd031d222c7f115922842)

20 months agore-add cascade caveats
Mike Bayer [Wed, 22 Nov 2023 15:58:00 +0000 (10:58 -0500)] 
re-add cascade caveats

these got removed and never restored in 2.0

References: https://github.com/sqlalchemy/sqlalchemy/discussions/10672
Change-Id: Ibbd9a8ab04556ebd581f9287b54fe1ffdaacee79
(cherry picked from commit 4279e715e0b4af819a0434daa5bf9e0c18789bec)

20 months agoupdate all errors / warnings in schema to use f strings
Mike Bayer [Sat, 18 Nov 2023 15:22:19 +0000 (10:22 -0500)] 
update all errors / warnings in schema to use f strings

Fixed issue where error reporting for unexpected schema item when creating
objects like :class:`_schema.Table` would incorrectly handle an argument
that was itself passed as a tuple, leading to a formatting error.  The
error message has been modernized to use f-strings.

this change necessitated an update to flake8 as version 5 was
mis-interpreting f-strings that had semicolons in them.
Black is also unable to format some of these f-strings which had
to be broken out, unclear if there is a newer Black available.

Fixes: #10654
Change-Id: I703e94282c27ccf06f4aa315e8a11bd97b719170
(cherry picked from commit 2458ceee94e7bd6e5bf8d9d7270be8819bbe772c)

20 months agoUpdate type annotation for DBAPI Cursor's executemany()
William Henry Hakim [Thu, 16 Nov 2023 14:11:26 +0000 (09:11 -0500)] 
Update type annotation for DBAPI Cursor's executemany()

### Description
As per https://groups.google.com/g/sqlalchemy/c/DkyffAgDmwM, fixes an issue with the DBAPI cursor's executemany() type signature.

### 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: #10644
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10644
Pull-request-sha: 0a1fe849b54e35cd5e417da79556dc94be3a0abc

Change-Id: I3af344f052a2f306876a528c528b1bf9cc0bdaa6
(cherry picked from commit 55bf2bf971cda82c2e3f58e9c211c74c3a6394a8)

20 months agoclarify connection pool release for session.commit/ rollback
Mike Bayer [Wed, 15 Nov 2023 18:50:19 +0000 (13:50 -0500)] 
clarify connection pool release for session.commit/ rollback

Change-Id: I71adf3ed9eb9f7c0abb50ecc9efe7c2df3c98705
(cherry picked from commit 3b4a97972131bbcbe53120400270faa4fce87594)

20 months agoMerge "always derive type from element in annotated case" into rel_2_0
mike bayer [Mon, 13 Nov 2023 13:27:30 +0000 (13:27 +0000)] 
Merge "always derive type from element in annotated case" into rel_2_0

20 months agoFix a typo (#10620)
Aleksandr Kiliushin [Sun, 12 Nov 2023 09:32:05 +0000 (13:32 +0400)] 
Fix a typo (#10620)

(cherry picked from commit fc6c2b19fd7f5cb89e0c405f5aa3b3360e4c4a93)

20 months agoTyping updates to fix errors found by mypy 1.7
Federico Caselli [Sat, 11 Nov 2023 15:26:57 +0000 (16:26 +0100)] 
Typing updates to fix errors found by mypy 1.7

Change-Id: I02046a72df88a82c8bc6e40b41f9d5b0d01a163e
(cherry picked from commit e45b9ffd421cd2a36208a763e20ff6c4e86aad90)

20 months agoVarious minor fixes
Federico Caselli [Sat, 4 Nov 2023 20:32:16 +0000 (21:32 +0100)] 
Various minor fixes

Fix typo in exported class in init. #10578
Improve warning for loaderes. #10579
Properly document ARRAY.contains. #10587
Mention how to set a schema to the automatically generated enums. #10583
Improve type of cache key dispatcher

Change-Id: I86e4f01f5d897b257246fe5f970b78e3444aca3e
(cherry picked from commit 1bb9c4b94483a25057bad3d78cf9956e8f292330)

20 months agoFix lint error
Federico Caselli [Wed, 8 Nov 2023 20:49:06 +0000 (21:49 +0100)] 
Fix lint error

Change-Id: Ifb53e125fc9fd759938908710b2474656dbf1ef9

20 months agoAdd trove classifier for 3.12 (#10599)
Jack McIvor [Tue, 7 Nov 2023 17:55:18 +0000 (17:55 +0000)] 
Add trove classifier for 3.12 (#10599)

(cherry picked from commit 8a583ad7bf65d5d9bf05568279723bc516de3ae3)

20 months agoFix syntax typo in doc/build/tutorial/data_select.rst (#10590)
Sebastián Ramírez [Mon, 6 Nov 2023 20:01:51 +0000 (00:01 +0400)] 
Fix syntax typo in doc/build/tutorial/data_select.rst (#10590)

(cherry picked from commit e00215cfcdab5186ab07889dda4a2280b5ad5d44)

20 months agoremove . in sys.path
Mike Bayer [Wed, 8 Nov 2023 20:20:24 +0000 (15:20 -0500)] 
remove . in sys.path

this should not be needed and is causing problems in python
3.12 due to the presence of the "changelog" directory

(cherry picked from commit 8faa17d4316772340295a677c54eccf647a221c9)

21 months agoalways derive type from element in annotated case
Mike Bayer [Mon, 6 Nov 2023 22:46:14 +0000 (17:46 -0500)] 
always derive type from element in annotated case

Fixed issue where use of :func:`_orm.foreign` annotation on a
non-initialized :func:`_orm.mapped_column` construct would produce an
expression without a type, which was then not updated at initialization
time of the actual column, leading to issues such as relationships not
determining ``use_get`` appropriately.

Fixes: #10597
Change-Id: I8339ba715ec6bd1f50888f8a424c3ac156e2364f
(cherry picked from commit 432eb350a4b81ba557f14d49ebd37cf5899d5423)

21 months agomove to rel_2_0
Mike Bayer [Mon, 6 Nov 2023 15:12:42 +0000 (10:12 -0500)] 
move to rel_2_0

Change-Id: Ic52aea08e17e67ab19afce6ccb8fe74ca59ecd4c

21 months agoFix link to change_4639in `doc/build/changelog/migration_20.rst` (#10585)
Sebastián Ramírez [Sat, 4 Nov 2023 20:22:29 +0000 (00:22 +0400)] 
Fix link to change_4639in `doc/build/changelog/migration_20.rst` (#10585)

21 months agoFix link to `/orm/queryguide/index` in `doc/build/changelog/migration_20.rst` (#10584)
Sebastián Ramírez [Sat, 4 Nov 2023 20:21:39 +0000 (00:21 +0400)] 
Fix link to `/orm/queryguide/index` in `doc/build/changelog/migration_20.rst` (#10584)

21 months agorepair new ORM test for Oracle, SQL Server
Mike Bayer [Sat, 4 Nov 2023 08:04:54 +0000 (04:04 -0400)] 
repair new ORM test for Oracle, SQL Server

Change-Id: Icbe5cf0a9a6cfdae9f6d0863af5734d6f43c517a

21 months agoVersion 2.0.24 placeholder
Mike Bayer [Thu, 2 Nov 2023 14:52:23 +0000 (10:52 -0400)] 
Version 2.0.24 placeholder

21 months ago- 2.0.23 rel_2_0_23
Mike Bayer [Thu, 2 Nov 2023 14:31:56 +0000 (10:31 -0400)] 
- 2.0.23

21 months agoimplement render_nulls for new style bulk ORM INSERT
Mike Bayer [Wed, 1 Nov 2023 22:06:49 +0000 (18:06 -0400)] 
implement render_nulls for new style bulk ORM INSERT

Implemented the :paramref:`_orm.Session.bulk_insert_mappings.render_nulls`
parameter for new style bulk ORM inserts, allowing ``render_nulls=True`` as
an execution option.   This allows for bulk ORM inserts with a mixture of
``None`` values in the parameter dictionaries to use a single batch of rows
for a given set of dicationary keys, rather than breaking up into batches
that omit the NULL columns from each INSERT.

Fixes: #10575
Change-Id: I47382bb586626e98d3964dfa8f55acb2c9c6d8d4

21 months agouse _extra_criteria to store with_expression() expression
Mike Bayer [Tue, 31 Oct 2023 18:56:37 +0000 (14:56 -0400)] 
use _extra_criteria to store with_expression() expression

this is an alternate version of the first patch, which adds extra
handling for the "expression" in local_opts.  this patch has
with_expression() use _extra_criteria directly, as this attribute
is currently unpurposed for column-based attributes.

Fixed caching bug where using the :func:`_orm.with_expression` construct in
conjunction with loader options :func:`_orm.selectinload`,
:func:`_orm.lazyload` would fail to substitute bound parameter values
correctly on subsequent caching runs.

Fixes: #10570
Change-Id: If6c74755580fe5b108056eebcb461d984410ff46

21 months agoadd note that secondary string is Python eval re: identifier names
Mike Bayer [Tue, 31 Oct 2023 02:14:21 +0000 (22:14 -0400)] 
add note that secondary string is Python eval re: identifier names

im not exactly sure why "secondary" string is a Python eval
as I dont know what kind of Python eval someone might put there.
Add explicit note about this referring to table names that have
non-Python identifier characters.

Fixes: #10563
Change-Id: I06fc933541ca1751201ee8a29444f81868f0c1cb

21 months agocherry-pick changelog update for 1.4.51
Mike Bayer [Sun, 29 Oct 2023 20:32:31 +0000 (16:32 -0400)] 
cherry-pick changelog update for 1.4.51

21 months agocherry-pick changelog from 1.4.50
Mike Bayer [Sun, 29 Oct 2023 20:32:30 +0000 (16:32 -0400)] 
cherry-pick changelog from 1.4.50

21 months agochangelog updates
Mike Bayer [Sun, 29 Oct 2023 20:15:52 +0000 (16:15 -0400)] 
changelog updates

Change-Id: I6b362500f1fab118920d61f8b6247521756922ff

21 months agoAdd bind casts for BIT on asyncpg
Sören Oldag [Thu, 26 Oct 2023 13:17:41 +0000 (09:17 -0400)] 
Add bind casts for BIT on asyncpg

Fixed SQL handling for "insertmanyvalues" when using the
:class:`.postgresql.BIT` datatype with the asyncpg backend.  The
:class:`.postgresql.BIT` on asyncpg apparently requires the use of an
asyncpg-specific `BitString` type which is currently exposed when using
this DBAPI, making it incompatible with other PostgreSQL DBAPIs that all
work with plain bitstrings here.  A future fix in version 2.1 will
normalize this datatype across all PG backends.   Pull request courtesy
Sören Oldag.

Fixes: #10532
Closes: #10533
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10533
Pull-request-sha: 528607d5b5b67c1b9c2edb39176b7e005db371f6

Change-Id: I879f2fc24b5650467b85f170c0def15834f75456

21 months agoadd precision interval test
Mike Bayer [Wed, 25 Oct 2023 13:53:21 +0000 (09:53 -0400)] 
add precision interval test

Change-Id: I11a50f245a66fa9df62c736ce24dd57501d58dbe
References: https://github.com/sqlalchemy/sqlalchemy/pull/10383#discussion_r1371771358

21 months agoremove type check decorators
Mike Bayer [Tue, 24 Oct 2023 20:05:48 +0000 (16:05 -0400)] 
remove type check decorators

in 598ae1d120a35ee9e19cf7f953c7dd51047954d6, we erroneously
merged "no_type_check" decorators.  we only merge typing that works
or requires "type: ignore", so remove these

Fixes: #9737
Change-Id: I0fdd2022df9b7b59482581957b77057094475647

21 months agoMerge "use oracle.INTERVAL for generic interval" into main
mike bayer [Tue, 24 Oct 2023 18:38:56 +0000 (18:38 +0000)] 
Merge "use oracle.INTERVAL for generic interval" into main

21 months agoMerge "add literal_processors for interval, PG and Oracle" into main
mike bayer [Tue, 24 Oct 2023 18:38:34 +0000 (18:38 +0000)] 
Merge "add literal_processors for interval, PG and Oracle" into main

21 months agoMerge "accommodate NULL at the compiler level for literal_render" into main
mike bayer [Tue, 24 Oct 2023 18:37:39 +0000 (18:37 +0000)] 
Merge "accommodate NULL at the compiler level for literal_render" into main

21 months agoMerge "Document workaround for aiosqlite savepoints" into main
mike bayer [Tue, 24 Oct 2023 16:12:04 +0000 (16:12 +0000)] 
Merge "Document workaround for aiosqlite savepoints" into main

21 months agoadd literal_processors for interval, PG and Oracle
indivar [Thu, 28 Sep 2023 17:43:57 +0000 (13:43 -0400)] 
add literal_processors for interval, PG and Oracle

Implemented "literal value processing" for the :class:`.Interval` datatype
for both the PostgreSQL and Oracle dialects, allowing literal rendering of
interval values.  Pull request courtesy Indivar Mishra.

Fixes: #9737
Closes: #10383
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10383
Pull-request-sha: bf3a73dfd9d329779e12037ae62dc1032e76d0f6

Change-Id: Ic1a1c505f23eeb681059303799d5fc8821aadacf

21 months agoaccommodate NULL at the compiler level for literal_render
Mike Bayer [Tue, 24 Oct 2023 16:06:24 +0000 (12:06 -0400)] 
accommodate NULL at the compiler level for literal_render

Added compiler-level None/NULL handling for the "literal processors" of all
datatypes that include literal processing, that is, where a value is
rendered inline within a SQL statement rather than as a bound parameter,
for all those types that do not feature explicit "null value" handling.
Previously this behavior was undefined and inconsistent.

Fixes: #10535
Change-Id: I746d19d6cec2aefa3244f5e5a6970950a698d96c

21 months agoMerge "move BYTEA test to PG suite" into main
mike bayer [Tue, 24 Oct 2023 15:25:46 +0000 (15:25 +0000)] 
Merge "move BYTEA test to PG suite" into main

21 months agoDocument workaround for aiosqlite savepoints
Vlastimil Zíma [Fri, 20 Oct 2023 17:58:21 +0000 (13:58 -0400)] 
Document workaround for aiosqlite savepoints

### Description
Update docs with workaround for SAVEPOINT in aiosqlite, based on https://github.com/sqlalchemy/sqlalchemy/discussions/10463

### Checklist
This pull request is:

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

Closes: #10491
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10491
Pull-request-sha: 0516c205d2c4c046d449b5684c13a06f813dabe1

Change-Id: I6bb92f18c99f2a53f5488a2d5812781cb2a003b7

21 months agoMerge "Fix --dbs test option" into main
mike bayer [Tue, 24 Oct 2023 14:49:20 +0000 (14:49 +0000)] 
Merge "Fix --dbs test option" into main

21 months agouse oracle.INTERVAL for generic interval
indivar [Fri, 20 Oct 2023 15:25:38 +0000 (11:25 -0400)] 
use oracle.INTERVAL for generic interval

Fixed issue in :class:`.Interval` datatype where the Oracle implementation
was not being used for DDL generation, leading to the ``day_precision`` and
``second_precision`` parameters to be ignored, despite being supported by
this dialect.  Pull request courtesy Indivar.

Fixes: #10509
Closes: #10513
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10513
Pull-request-sha: a3b901978504b1bc726f722fc27ca4827de05274

Change-Id: I074afeeac182567f9104c5175b81c735d87e1352

21 months agomove BYTEA test to PG suite
Mike Bayer [Tue, 24 Oct 2023 14:15:51 +0000 (10:15 -0400)] 
move BYTEA test to PG suite

we can't have any postgresql imports in suite/test_insert.py

Change-Id: I81f364169c775bef71dc77db0a6e9d6bc530e79d

21 months agoMerge "Fix identity column reflection failure" into main
mike bayer [Mon, 23 Oct 2023 18:34:29 +0000 (18:34 +0000)] 
Merge "Fix identity column reflection failure" into main

21 months agoMerge "run declarative scan for non-mapped annotated if allow_unmapped" into main
mike bayer [Mon, 23 Oct 2023 18:31:20 +0000 (18:31 +0000)] 
Merge "run declarative scan for non-mapped annotated if allow_unmapped" into main

21 months agoFix --dbs test option
Federico Caselli [Sun, 22 Oct 2023 09:25:28 +0000 (11:25 +0200)] 
Fix --dbs test option

At some point a version of pytest seems to have broken the
previous implementation

Change-Id: I7dfd4c8743f5214a3110dd1b6da4fa8296895899

21 months agoFix identity column reflection failure
Gord Thompson [Fri, 20 Oct 2023 14:19:42 +0000 (08:19 -0600)] 
Fix identity column reflection failure

Fixes: #10504
Fix reflection failure for bigint identity column with
a large identity start value (more than 18 digits).

Change-Id: I8a7ec114e4596b1710d789a4a4fb08013edd80ce

21 months agoMerge "Remove compare_against_backend" into main
mike bayer [Fri, 20 Oct 2023 18:14:02 +0000 (18:14 +0000)] 
Merge "Remove compare_against_backend" into main

21 months agorun declarative scan for non-mapped annotated if allow_unmapped
Mike Bayer [Fri, 20 Oct 2023 14:19:35 +0000 (10:19 -0400)] 
run declarative scan for non-mapped annotated if allow_unmapped

Fixed issue where the ``__allow_unmapped__`` directive failed to allow for
legacy :class:`.Column` / :func:`.deferred` mappings that nonetheless had
annotations such as ``Any`` or a specific type without ``Mapped[]`` as
their type, without errors related to locating the attribute name.

issue is not ticketed yet but is coming

Fixes: #10516
Change-Id: I471d6838f4dcc113addd284a39a5bb0b885b64ea

21 months agoMerge "dont write dupe idents w different drivers in the idents file" into main
mike bayer [Fri, 20 Oct 2023 18:13:09 +0000 (18:13 +0000)] 
Merge "dont write dupe idents w different drivers in the idents file" into main

21 months agoMerge "manufacture empty result for DELETE..RETURNING w/ no description" into main
mike bayer [Fri, 20 Oct 2023 17:49:15 +0000 (17:49 +0000)] 
Merge "manufacture empty result for DELETE..RETURNING w/ no description" into main

21 months agodont write dupe idents w different drivers in the idents file
Mike Bayer [Fri, 20 Oct 2023 17:31:15 +0000 (13:31 -0400)] 
dont write dupe idents w different drivers in the idents file

Change-Id: I474b40327fcc40a8a6eb4c537a4b80f0eea37162

21 months agoMerge "dont mis-render value from previous loop iteration" into main
mike bayer [Fri, 20 Oct 2023 17:08:44 +0000 (17:08 +0000)] 
Merge "dont mis-render value from previous loop iteration" into main

21 months agoMerge "revise argument to mysqlclient/pymysql ping" into main
mike bayer [Fri, 20 Oct 2023 13:27:07 +0000 (13:27 +0000)] 
Merge "revise argument to mysqlclient/pymysql ping" into main

21 months agoMerge "add aioodbc support for SQL Server" into main
mike bayer [Thu, 19 Oct 2023 17:06:43 +0000 (17:06 +0000)] 
Merge "add aioodbc support for SQL Server" into main

21 months agoMerge "fix AsyncSession.close_all()" into main
Federico Caselli [Thu, 19 Oct 2023 17:05:58 +0000 (17:05 +0000)] 
Merge "fix AsyncSession.close_all()" into main

21 months agoDoc: Update doc/build/tutorial/data_select.rst (#10506)
AmirSoroush [Thu, 19 Oct 2023 16:44:26 +0000 (19:44 +0300)] 
Doc: Update doc/build/tutorial/data_select.rst (#10506)

Removed an extra "that" in a sentence.

21 months agomanufacture empty result for DELETE..RETURNING w/ no description
Mike Bayer [Thu, 19 Oct 2023 16:14:14 +0000 (12:14 -0400)] 
manufacture empty result for DELETE..RETURNING w/ no description

Established a workaround for what seems to be an intrinsic issue across
MySQL/MariaDB drivers where a RETURNING result for DELETE DML which returns
no rows using SQLAlchemy's "empty IN" criteria fails to provide a
cursor.description, which then yields result that returns no rows,
leading to regressions for the ORM that in the 2.0 series uses RETURNING
for bulk DELETE statements for the "synchronize session" feature. To
resolve, when the specific case of "no description when RETURNING was
given" is detected, an "empty result" with a correct cursor description is
generated and used in place of the non-working cursor.

Fixes: #10505
Change-Id: Ib56f1ec5746e2b3212e563169353bc023db84099

21 months agodont mis-render value from previous loop iteration
Mike Bayer [Thu, 19 Oct 2023 15:21:26 +0000 (11:21 -0400)] 
dont mis-render value from previous loop iteration

Fixed issue where using the same bound parameter more than once with
``literal_execute=True`` in some combinations with other literal rendering
parameters would cause the wrong values to render due to an iteration
issue.

Fixes: #10142
Change-Id: Idde314006568e3445558f0104aed9d2f4af72b56

21 months agorevise argument to mysqlclient/pymysql ping
Mike Bayer [Tue, 17 Oct 2023 22:54:23 +0000 (18:54 -0400)] 
revise argument to mysqlclient/pymysql ping

Repaired a new incompatibility in the MySQL "pre-ping" routine where the
``False`` argument passed to ``connection.ping()``, which is intended to
disable an unwanted "automatic reconnect" feature,  is being deprecated in
MySQL drivers and backends, and is producing warnings for some versions of
MySQL's native client drivers.  It's removed for mysqlclient, whereas for
PyMySQL and drivers based on PyMySQL, the parameter will be deprecated and
removed at some point, so API introspection is used to future proof against
these various stages of removal.

Fixes: #10492
Change-Id: I8a52428c6f93a03b66a605cb0b85cc5924803d6d
references: #10489

21 months agofix AsyncSession.close_all()
Bryan不可思议 [Wed, 18 Oct 2023 20:31:45 +0000 (16:31 -0400)] 
fix AsyncSession.close_all()

Fixed bug with method :meth:`_asyncio.AsyncSession.close_all`
that was not working correctly.
Also added function :func:`_asyncio.close_all_sessions` that's
the equivalent of :func:`_orm.close_all_sessions`.

Fixes: #10421
Closes: #10429
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10429
Pull-request-sha: a35c29d41213bd79bfa73ac559a29035ca4e9eb9

Change-Id: If2c3f0130a71b239382c2ea11a3436788ee242be

21 months agoRemove compare_against_backend
Federico Caselli [Wed, 18 Oct 2023 17:51:00 +0000 (19:51 +0200)] 
Remove compare_against_backend

Removed unused placeholder method :meth:`.TypeEngine.compare_against_backend`
This method was used by very old versions of Alembic.
See https://github.com/sqlalchemy/alembic/issues/1293 for details.
Follow up of alembic change I6f480711ec94cd4113d3f0ca114d143b49b8d869

Change-Id: I48ba2b26128ba6f74cb0b2c54caa6f7d2a711257

21 months agoMerge "fix(#10056): keep nullable as true for mariadb generated columns" into main
mike bayer [Tue, 17 Oct 2023 13:30:54 +0000 (13:30 +0000)] 
Merge "fix(#10056): keep nullable as true for mariadb generated columns" into main

21 months agofix(#10056): keep nullable as true for mariadb generated columns
indivar [Mon, 16 Oct 2023 18:53:04 +0000 (14:53 -0400)] 
fix(#10056): keep nullable as true for mariadb generated columns

mariaDB does not support setting NOT NULL for generated column
ref: https://mariadb.com/kb/en/generated-columns/#statement-support

added a check in `get_column_specification` for mariadb, checking
if user has not specified nullable set it as True for computed column,
but if user has explicitly set as False raise a compile error.

added testcase for same

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

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

**Have a nice day!**

Closes: #10354
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10354
Pull-request-sha: 68035e0f77884f361bdcad0514ea731814cb1a34

Change-Id: I00188cf899c0a2efe759e06e510243fbdb1a6dcf

21 months agoimplement eager_grouping for expression clauselists
Mike Bayer [Mon, 16 Oct 2023 17:01:42 +0000 (13:01 -0400)] 
implement eager_grouping for expression clauselists

the expression clauselist feature added in #7744 failed to accommodate
this parameter that is used only by the PostgreSQL JSON
operators.

Fixed 2.0 regression caused by :ticket:`7744` where chains of expressions
involving PostgreSQL JSON operators combined with other operators such as
string concatenation would lose correct parenthesization, due to an
implementation detail specific to the PostgreSQL dialect.

Fixes: #10479
Change-Id: Ic168bf6afd8bf1cfa648f2bad22fdd7254feaa34

21 months agoFix `get_one` return value description
Jochen Kupperschmidt [Sat, 14 Oct 2023 19:08:57 +0000 (15:08 -0400)] 
Fix `get_one` return value description

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

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

The `get_one()` method is described as raising an error if no row is found instead of returning `None` (as `get()` does). Also, the return type hint prohibits `None`.

### 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: #10473
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10473
Pull-request-sha: 1cd2c2a2df2c91a303e459c8f0c5dc950d8c7b39

Change-Id: Iaf69b05d99f4ed0df922f34f27be0b46c1410f7e

21 months agoadd aioodbc support for SQL Server
Mike Bayer [Mon, 2 Oct 2023 18:07:29 +0000 (14:07 -0400)] 
add aioodbc support for SQL Server

Added support for the ``aioodbc`` driver implemented for SQL Server,
which builds on top of the pyodbc and general aio* dialect architecture.

Fixes: #6521
Change-Id: Ife0f6e219766e396079437e99b8938692133b291

21 months agoMerge "ensure ClassVar succeeds in cleanup_mapped_str_annotation" into main
mike bayer [Fri, 13 Oct 2023 20:36:11 +0000 (20:36 +0000)] 
Merge "ensure ClassVar succeeds in cleanup_mapped_str_annotation" into main

21 months agoMerge "amend cx_Oracle version checks, setup.cfg to oracle 8" into main
mike bayer [Fri, 13 Oct 2023 20:35:31 +0000 (20:35 +0000)] 
Merge "amend cx_Oracle version checks, setup.cfg to oracle 8" into main

21 months agoensure ClassVar succeeds in cleanup_mapped_str_annotation
Mike Bayer [Fri, 13 Oct 2023 19:27:40 +0000 (15:27 -0400)] 
ensure ClassVar succeeds in cleanup_mapped_str_annotation

Fixed bug in ORM annotated declarative where using a ``ClassVar`` that
nonetheless referred in some way to an ORM mapped class name would fail to
be interpreted as a ``ClassVar`` that's not mapped.

Fixes: #10472
Change-Id: I6606b0f0222ef088e594eb3b0c0653d983d6ff89

21 months agoamend cx_Oracle version checks, setup.cfg to oracle 8
Mike Bayer [Fri, 13 Oct 2023 18:01:07 +0000 (14:01 -0400)] 
amend cx_Oracle version checks, setup.cfg to oracle 8

Fixed issue where the cx_Oracle dialect claimed to support a lower
cx_Oracle version (7.x) than was actually supported in practice within the
2.0 series of SQLAlchemy. The dialect imports symbols that are only in
cx_Oracle 8 or higher, so runtime dialect checks as well as setup.cfg
requirements have been updated to reflect this compatibility.

Fixes: #10470
Change-Id: Ic955c085e2239a632031d5a80a8b9a9c697a88f8

21 months agoVersion 2.0.23 placeholder
Mike Bayer [Thu, 12 Oct 2023 20:52:21 +0000 (16:52 -0400)] 
Version 2.0.23 placeholder

21 months ago- 2.0.22 rel_2_0_22
Mike Bayer [Thu, 12 Oct 2023 20:38:20 +0000 (16:38 -0400)] 
- 2.0.22