]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agofixup: Import from non-private 9753/head
Nick Crews [Wed, 17 May 2023 23:55:55 +0000 (15:55 -0800)] 
fixup: Import from non-private

2 years agofixup: Add more explanation to versionadded::
Nick Crews [Wed, 17 May 2023 23:50:58 +0000 (15:50 -0800)] 
fixup: Add more explanation to versionadded::

2 years agofixup: linewrap changelog blurb better
Nick Crews [Wed, 17 May 2023 23:45:06 +0000 (15:45 -0800)] 
fixup: linewrap changelog blurb better

2 years agofixup: try_cast: restore mssql implementation
Nick Crews [Mon, 15 May 2023 19:21:22 +0000 (11:21 -0800)] 
fixup: try_cast: restore mssql implementation

From comments at
https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4605

2 years agofixup: run black correctly
Nick Crews [Wed, 10 May 2023 21:52:21 +0000 (13:52 -0800)] 
fixup: run black correctly

2 years agofixup: indentation
Nick Crews [Wed, 10 May 2023 20:20:13 +0000 (12:20 -0800)] 
fixup: indentation

2 years agofixup: mypy
Nick Crews [Wed, 10 May 2023 18:53:05 +0000 (10:53 -0800)] 
fixup: mypy

2 years agofixup: make tests work
Nick Crews [Wed, 10 May 2023 18:47:03 +0000 (10:47 -0800)] 
fixup: make tests work

2 years agofixup: format with pre-commit
Nick Crews [Wed, 10 May 2023 17:40:30 +0000 (09:40 -0800)] 
fixup: format with pre-commit

2 years agofixup: docstring tweak
Nick Crews [Wed, 10 May 2023 17:01:59 +0000 (09:01 -0800)] 
fixup: docstring tweak

2 years agofixup: give me credit in changelog
Nick Crews [Wed, 10 May 2023 17:01:44 +0000 (09:01 -0800)] 
fixup: give me credit in changelog

2 years agofixup: try_cast: move visit_try_cast() to StrSQLCompiler
Nick Crews [Wed, 10 May 2023 16:13:45 +0000 (08:13 -0800)] 
fixup: try_cast: move visit_try_cast() to StrSQLCompiler

2 years agofixup: try_cast: v5
Nick Crews [Wed, 10 May 2023 16:07:46 +0000 (08:07 -0800)] 
fixup: try_cast: v5

- Tweak docs to be explicit that only MSSQL
  is currently supported.
- Update try_cast() docstring to better follow
the conventions of cast()
(and just be better in general)
- export try_cast from sql/__init__.py

2 years agofixup: try_cast: make re-exports explicit
Nick Crews [Tue, 9 May 2023 19:01:40 +0000 (11:01 -0800)] 
fixup: try_cast: make re-exports explicit

2 years agofixup: try_cast: move test
Nick Crews [Tue, 9 May 2023 19:01:27 +0000 (11:01 -0800)] 
fixup: try_cast: move test

2 years agofixup: try_cast v2
Nick Crews [Tue, 9 May 2023 18:51:42 +0000 (10:51 -0800)] 
fixup: try_cast v2

- update changelog entry
- don't deprecate accessing try_cast from mssql. Revert my test change
  to be consistent.
- re-export try_cast from the root place in mssql/__init__.py
- Move visit_try_cast() to base compiler

Still not sure exactly about where the test should live,
since it only should work for mssql, so I'm not sure how to
add it to the generic tests but
specify it to run only for mssql.

2 years agoMove try_cast() from mssql to base
Nick Crews [Mon, 8 May 2023 23:07:58 +0000 (15:07 -0800)] 
Move try_cast() from mssql to base

Other backends besides mssql support an operation like try_cast. Move it
to a common place so they can all implement it.

Fixes: #9752
Closes: #9752
2 years agoFix usage of `Annotated` in `DeclarativeBase` docstring (#9751)
Viicos [Mon, 8 May 2023 20:19:47 +0000 (22:19 +0200)] 
Fix usage of `Annotated` in `DeclarativeBase` docstring (#9751)

2 years agofix test on old sqlite
Federico Caselli [Fri, 5 May 2023 21:22:46 +0000 (23:22 +0200)] 
fix test on old sqlite

Change-Id: Ic7dbb7df6a10077eb28a721e151b2194ab3b1634

2 years agoadd explicit step to set populate_existing for bulk insert
Mike Bayer [Fri, 5 May 2023 13:16:10 +0000 (09:16 -0400)] 
add explicit step to set populate_existing for bulk insert

Fixed issue in new :ref:`orm_queryguide_upsert_returning` feature where the
``populate_existing`` execution option was not being propagated to the
loading option, preventing existing attributes from being refreshed
in-place.

Fixes: #9746
Change-Id: I3efcab644e2b5874c6b265d5313f353c051db629

2 years agoMerge "Add public alias of type _ColumnExpressionArgument" into main
mike bayer [Thu, 4 May 2023 12:56:59 +0000 (12:56 +0000)] 
Merge "Add public alias of type _ColumnExpressionArgument" into main

2 years agoMerge "adjust fwd_ref logic" into main
mike bayer [Thu, 4 May 2023 12:54:18 +0000 (12:54 +0000)] 
Merge "adjust fwd_ref logic" into main

2 years agoMerge "improve natural_path usage in two places" into main
mike bayer [Thu, 4 May 2023 12:53:40 +0000 (12:53 +0000)] 
Merge "improve natural_path usage in two places" into main

2 years agoVersion 2.0.13 placeholder
Mike Bayer [Sun, 30 Apr 2023 21:42:23 +0000 (17:42 -0400)] 
Version 2.0.13 placeholder

2 years ago- 2.0.12 rel_2_0_12
Mike Bayer [Sun, 30 Apr 2023 21:34:36 +0000 (17:34 -0400)] 
- 2.0.12

2 years agocherry-pick changelog update for 1.4.49
Mike Bayer [Sun, 30 Apr 2023 21:33:17 +0000 (17:33 -0400)] 
cherry-pick changelog update for 1.4.49

2 years agocherry-pick changelog from 1.4.48
Mike Bayer [Sun, 30 Apr 2023 21:33:17 +0000 (17:33 -0400)] 
cherry-pick changelog from 1.4.48

2 years agoadjust verbiage
Mike Bayer [Sun, 30 Apr 2023 21:22:44 +0000 (17:22 -0400)] 
adjust verbiage

Change-Id: Icc8f201d63e4cc2e7df2f42acb28a6dc84a58342

2 years agoMerge "do not allow non-cache-key entity objects in annotations" into main
mike bayer [Sun, 30 Apr 2023 21:17:37 +0000 (21:17 +0000)] 
Merge "do not allow non-cache-key entity objects in annotations" into main

2 years agoMerge "Add scalar example in association proxy examples" into main
mike bayer [Sun, 30 Apr 2023 19:06:13 +0000 (19:06 +0000)] 
Merge "Add scalar example in association proxy examples" into main

2 years agodo not allow non-cache-key entity objects in annotations
Mike Bayer [Sun, 30 Apr 2023 17:56:33 +0000 (13:56 -0400)] 
do not allow non-cache-key entity objects in annotations

Fixed critical caching issue where combination of :func:`_orm.aliased()`
:func:`_sql.case` and :func:`_hybrid.hybrid_property` expressions would
cause a cache key mismatch, leading to cache keys that held onto the actual
:func:`_orm.aliased` object while also not matching each other, filling up
the cache.

Fixes: #9728
Change-Id: I700645b5629a81a0104cf923db72a7421fa43ff4

2 years agoSupport control char reflection in mysql mariadb
Federico Caselli [Sat, 29 Apr 2023 10:07:32 +0000 (12:07 +0200)] 
Support control char reflection in mysql mariadb

Fixed issues regarding reflection of comments for :class:`_schema.Table`
and :class:`_schema.Column` objects, where the comments contained control
characters such as newlines. Additional testing support for these
characters as well as extended Unicode characters in table and column
comments (the latter of which aren't supported by MySQL/MariaDB) added to
testing overall.

Fixes: #9722
Change-Id: Id18bf758fdb6231eb705c61eeaf74bb9fa472601

2 years agoimprove natural_path usage in two places
Mike Bayer [Thu, 27 Apr 2023 20:48:25 +0000 (16:48 -0400)] 
improve natural_path usage in two places

Fixed loader strategy pathing issues where eager loaders such as
:func:`_orm.joinedload` / :func:`_orm.selectinload` would fail to traverse
fully for many-levels deep following a load that had a
:func:`_orm.with_polymorphic` or similar construct as an interim member.

Here we can take advantage of 2.0's refactoring of strategy_options
to identify the "chop_path" concept can be simplified to work
with "natural" paths alone.

In addition, identified existing
logic in PropRegistry that works fine, but needed the "is_unnatural"
attribute to be more accurate for a given path, so we set that
up front to True if the ancestor is_unnatural.

Fixes: #9715
Change-Id: Ie6b3f55b6a23d0d32628afd22437094263745114

2 years agoAdd scalar example in association proxy examples
Federico Caselli [Fri, 28 Apr 2023 20:26:41 +0000 (22:26 +0200)] 
Add scalar example in association proxy examples

Fixes: #9699
Change-Id: I73f800b9b3676cbf0ac04534c0ca4e40f23bf0ec

2 years agoadjust fwd_ref logic
Mike Bayer [Fri, 28 Apr 2023 03:00:18 +0000 (23:00 -0400)] 
adjust fwd_ref logic

Fixed issue where ORM Annotated Declarative would not resolve forward
references correctly in all cases; in particular, when using
``from __future__ import annotations`` in combination with Pydantic
dataclasses.

Change-Id: If643c9a4ac7e217d4cb3a7d09b96cfd49432c44e
References: #9717

2 years agofix callcounts for postgresql
Mike Bayer [Fri, 28 Apr 2023 01:40:57 +0000 (21:40 -0400)] 
fix callcounts for postgresql

due to recent perf changes the PG callcounts also need
adjustment

Change-Id: I4375cccb1ce9e3cf1964ab48da748dbbc1ead37c

2 years agoAdd public alias of type _ColumnExpressionArgument
Federico Caselli [Mon, 24 Apr 2023 09:24:32 +0000 (11:24 +0200)] 
Add public alias of type _ColumnExpressionArgument

Added type ``ColumnExpressionArgument`` as a public alias of an internal
type. This type is useful since it's what' accepted by the sqlalchemy in
many api calls, such as :meth:`_sql.Select.where`, :meth:`_sql.and` and
many other.

Fixes: #9656
Change-Id: I79a38a0c1417d0ed1b6efff00497dba5e2be4f79

2 years agoFix import for selectinload in docs (#9712)
Holly Becker [Thu, 27 Apr 2023 19:06:10 +0000 (12:06 -0700)] 
Fix import for selectinload in docs (#9712)

selectinload is in sqlalchemy.orm, not sqlalchemy

2 years agouse a lot more random names
Mike Bayer [Thu, 27 Apr 2023 13:49:07 +0000 (09:49 -0400)] 
use a lot more random names

very small number of tiny names generated by
random_names() could cause _ordered_name_fixture() to
run out of names.

Fixes: #9706
Change-Id: I3df00c9cf99e76fe82eb535c7fe589b73b10cd67

2 years agoVersion 2.0.12 placeholder
Mike Bayer [Thu, 27 Apr 2023 01:56:00 +0000 (21:56 -0400)] 
Version 2.0.12 placeholder

2 years ago- 2.0.11 rel_2_0_11
Mike Bayer [Thu, 27 Apr 2023 01:43:30 +0000 (21:43 -0400)] 
- 2.0.11

2 years agochangelog updates
Mike Bayer [Thu, 27 Apr 2023 01:37:20 +0000 (21:37 -0400)] 
changelog updates

Additionally add mssql DOUBLE_PRECISION to mssql.__all__

Change-Id: I93f2db85feeff116278c5c6d0678e20d039a3e1f

2 years agoMerge "Performance improvement in Row" into main
mike bayer [Thu, 27 Apr 2023 00:13:38 +0000 (00:13 +0000)] 
Merge "Performance improvement in Row" into main

2 years agoMerge "support parameters in all ORM insert modes" into main
mike bayer [Thu, 27 Apr 2023 00:13:00 +0000 (00:13 +0000)] 
Merge "support parameters in all ORM insert modes" into main

2 years agoMerge "ensure correct cast for floats vs. numeric; other fixes" into main
mike bayer [Thu, 27 Apr 2023 00:06:44 +0000 (00:06 +0000)] 
Merge "ensure correct cast for floats vs. numeric; other fixes" into main

2 years agoMerge "disable "bytes" handler for all drivers other than psycopg2" into main
mike bayer [Wed, 26 Apr 2023 20:57:54 +0000 (20:57 +0000)] 
Merge "disable "bytes" handler for all drivers other than psycopg2" into main

2 years agoMerge "Prebuild the row string to position lookup for Rows" into main
mike bayer [Wed, 26 Apr 2023 20:25:35 +0000 (20:25 +0000)] 
Merge "Prebuild the row string to position lookup for Rows" into main

2 years agoPerformance improvement in Row
Federico Caselli [Wed, 19 Apr 2023 22:39:18 +0000 (18:39 -0400)] 
Performance improvement in Row

Various performance improvements to Row instanciation
- avoid passing processors if they are all None
- improve processor logic in cython
- improve tuplegetter using slices when contiguous indexes are used

Some timing follow.

In particular [base_]row_new_proc that tests using processors has
a 25% improvement compared to before in cython.
Looking at the [b]row_new_proc_none that test a list of processors
all None, this has 50% improvement in cython when passing the none list,
but in this patch it would usually be disabled by passing None, so the
performance gain is actually 90%, since it would run the case
[base_]row_new.

Tuplegetter is a bit faster in the single item get and when getting
sequential indexes (like indexes 1,2,3,4) at the cost of a bit
longer creation time in python, cython is mostly the same.

Current times
                    | python      | cython      | cy / py     |
base_row_new        | 0.639817400 | 0.118265500 | 0.184842582 |
row_new             | 0.680355100 | 0.129714600 | 0.190657202 |
base_row_new_proc   | 3.076538900 | 1.488428600 | 0.483799701 |
row_new_proc        | 3.119700100 | 1.532197500 | 0.491136151 |
brow_new_proc_none  | 1.917702300 | 0.475511500 | 0.247958977 |
row_new_proc_none   | 1.956253300 | 0.497803100 | 0.254467609 |

tuplegetter_one     | 0.152512600 | 0.148523900 | 0.973846751 |
tuplegetter_many    | 0.184394100 | 0.184511500 | 1.000636680 |
tuplegetter_seq     | 0.154832800 | 0.156270100 | 1.009282917 |
tuplegetter_new_one | 0.523730000 | 0.343402200 | 0.655685563 |
tuplegetter_new_many| 0.738924400 | 0.420961400 | 0.569694816 |
tuplegetter_new_seq | 1.062036900 | 0.495462000 | 0.466520514 |

Parent commit times
                    | python      | cython      | cy / py     |
base_row_new        | 0.643890800 | 0.113548300 | 0.176347138 |
row_new             | 0.674885900 | 0.124391800 | 0.184315304 |
base_row_new_proc   | 3.072020400 | 2.017367000 | 0.656690626 |
row_new_proc        | 3.109943400 | 2.048359400 | 0.658648450 |
brow_new_proc_none  | 1.967133700 | 1.006326000 | 0.511569702 |
row_new_proc_none   | 1.960814900 | 1.025217800 | 0.522852922 |

tuplegetter_one     | 0.197359900 | 0.205999000 | 1.043773330 |
tuplegetter_many    | 0.196575900 | 0.194888500 | 0.991416038 |
tuplegetter_seq     | 0.192723900 | 0.205635000 | 1.066992729 |
tuplegetter_new_one | 0.534644500 | 0.414311700 | 0.774929322 |
tuplegetter_new_many| 0.479376500 | 0.417448100 | 0.870814694 |
tuplegetter_new_seq | 0.481580200 | 0.412697900 | 0.856966088 |

Change-Id: I2ca1f49dca2beff625c283f1363c29c8ccc0c3f7

2 years agosupport parameters in all ORM insert modes
Mike Bayer [Sat, 1 Apr 2023 15:56:56 +0000 (11:56 -0400)] 
support parameters in all ORM insert modes

Fixed 2.0 regression where use of :func:`_sql.bindparam()` inside of
:meth:`_dml.Insert.values` would fail to be interpreted correctly when
executing the :class:`_dml.Insert` statement using the ORM
:class:`_orm.Session`, due to the new ORM-enabled insert feature not
implementing this use case.

In addition, the bulk INSERT and UPDATE features now add these
capabilities:

* The requirement that extra parameters aren't passed when using ORM
INSERT using the "orm" dml_strategy setting is lifted.
* The requirement that additional WHERE criteria is not passed when using
ORM UPDATE using the "bulk" dml_strategy setting is lifted.  Note that
in this case, the check for expected row count is turned off.

Fixes: #9583
Change-Id: I539c18893b697caeab5a5f0195a27d4f0487e728

2 years agoensure correct cast for floats vs. numeric; other fixes
Mike Bayer [Wed, 26 Apr 2023 14:34:46 +0000 (10:34 -0400)] 
ensure correct cast for floats vs. numeric; other fixes

Fixed regression caused by the fix for :ticket:`9618` where floating point
values would lose precision being inserted in bulk, using either the
psycopg2 or psycopg drivers.

Implemented the :class:`_sqltypes.Double` type for SQL Server, having it
resolve to ``REAL``, or :class:`_mssql.REAL`, at DDL rendering time.

Fixed issue in Oracle dialects where ``Decimal`` returning types such as
:class:`_sqltypes.Numeric` would return floating point values, rather than
``Decimal`` objects, when these columns were used in the
:meth:`_dml.Insert.returning` clause to return INSERTed values.

Fixes: #9701
Change-Id: I8865496a6ccac6d44c19d0ca2a642b63c6172da9

2 years agowrite out a full doc for both run_sync methods
Mike Bayer [Wed, 26 Apr 2023 19:32:56 +0000 (15:32 -0400)] 
write out a full doc for both run_sync methods

Fixes: #9705
Change-Id: I705463b9984f207f2268da6ebd80f07b68aa08f0

2 years agoPrebuild the row string to position lookup for Rows
J. Nick Koston [Wed, 19 Apr 2023 22:39:18 +0000 (18:39 -0400)] 
Prebuild the row string to position lookup for Rows

Improved :class:`_engine.Row` implementation to optimize
``__getattr__`` performance.
The serialization of a :class:`_engine.Row` to pickle has changed with
this change. Pickle saved by older SQLAlchemy versions can still be loaded,
but new pickle saved by this version cannot be loaded by older ones.

Fixes: #9678
Closes: #9668
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9668
Pull-request-sha: 86b8ccd1959dbd91b1208f7a648a91f217e1f866

Change-Id: Ia85c26a59e1a57ba2bf0d65578c6168f82a559f2

2 years agoMerge "Fix `RowMapping`'s `Mapping` type to reflect that it supports `Column`s or...
mike bayer [Tue, 25 Apr 2023 17:23:33 +0000 (17:23 +0000)] 
Merge "Fix `RowMapping`'s `Mapping` type to reflect that it supports `Column`s or strings" into main

2 years agoFixed bug in `URL.normalized_query`
Federico Caselli [Fri, 21 Apr 2023 20:26:11 +0000 (22:26 +0200)] 
Fixed bug in `URL.normalized_query`

Fixed a bug that prevented use of :attr:`_engine.URL.normalized_query` in
SQLAlchemy v2.

Fixes: #9682
Change-Id: I2704154af34f438b4cbb290602fc936c1184c074

2 years agoMerge "Adding typing to Postgres dialect file." into main
mike bayer [Tue, 25 Apr 2023 16:44:00 +0000 (16:44 +0000)] 
Merge "Adding typing to Postgres dialect file." into main

2 years agodisable "bytes" handler for all drivers other than psycopg2
J. Nick Koston [Tue, 25 Apr 2023 02:32:17 +0000 (22:32 -0400)] 
disable "bytes" handler for all drivers other than psycopg2

Improved row processing performance for "binary" datatypes by making the
"bytes" handler conditional on a per driver basis.  As a result, the
"bytes" result handler has been disabled for nearly all drivers other than
psycopg2, all of which in modern forms support returning Python "bytes"
directly.  Pull request courtesy J. Nick Koston.

Fixes: #9680
Closes: #9681
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9681
Pull-request-sha: 4f2fd88bd9af54c54438a3b72a2f30384b0f8898

Change-Id: I394bdcbebaab272e63b13cc02f60813b7aa76839

2 years ago:pencil2: Fix repetition for same reference page on documentation (#9694)
HoonCheol Shin [Sun, 23 Apr 2023 15:37:10 +0000 (00:37 +0900)] 
:pencil2: Fix repetition for same reference page on documentation (#9694)

* :pencil2: remove repeat for same reference

* :pencil2: apply the suggestion from @zzzeek

2 years agorepair large_resultsets
Mike Bayer [Sat, 22 Apr 2023 21:18:16 +0000 (17:18 -0400)] 
repair large_resultsets

this is ahead of https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4581/

Change-Id: If8a36e457bdb62ddca04e39bb4c1288d4fa53c20

2 years agosupport slice access for .c
Mike Bayer [Sat, 22 Apr 2023 13:41:49 +0000 (09:41 -0400)] 
support slice access for .c

Added support for slice access with :class:`.ColumnCollection`, e.g.
``table.c[0:5]``, ``subquery.c[:-1]`` etc. Slice access returns a sub
:class:`.ColumnCollection` in the same way as passing a tuple of keys. This
is a natural continuation of the key-tuple access added for :ticket:`8285`,
which it appears to be an oversight that this usage was omitted.

Change-Id: I6378642f39501ffbbae4acadf1dc38a43c39d722
References: #8285
References: #9690

2 years agoVersion 2.0.11 placeholder
Mike Bayer [Fri, 21 Apr 2023 20:02:41 +0000 (16:02 -0400)] 
Version 2.0.11 placeholder

2 years ago- 2.0.10 rel_2_0_10
Mike Bayer [Fri, 21 Apr 2023 19:45:19 +0000 (15:45 -0400)] 
- 2.0.10

2 years agorestore fallback for uow test
Mike Bayer [Fri, 21 Apr 2023 19:17:39 +0000 (15:17 -0400)] 
restore fallback for uow test

in cf6872d3bdf1a8a9613e85369 I decided this test should
be able to run in all cases, however apparently on windows
/ py37 on GH actions something goes wrong, so restore the skip
to that case.

Change-Id: Iaf4db313c20ce30469032af930b7dc86417d0705

2 years agochangelog fixes; edits
Mike Bayer [Fri, 21 Apr 2023 19:00:47 +0000 (15:00 -0400)] 
changelog fixes; edits

Change-Id: I6bbef2416f864d1414d56f9bf39026156aed5e67

2 years agoMerge "Add name_func optional attribute for asyncpg adapter" into main
Federico Caselli [Fri, 21 Apr 2023 18:57:01 +0000 (18:57 +0000)] 
Merge "Add name_func optional attribute for asyncpg adapter" into main

2 years agoAdd name_func optional attribute for asyncpg adapter
Pavel Sirotkin [Thu, 20 Apr 2023 17:40:04 +0000 (13:40 -0400)] 
Add name_func optional attribute for asyncpg adapter

I faced an issue related to pg bouncer and prepared statement cache flow in asyncpg dialect. Regarding this discussion https://github.com/sqlalchemy/sqlalchemy/issues/6467 I prepared PR to support an optional parameter `name` in prepared statement which is allowed, since 0.25.0 version in `asyncpg` https://github.com/MagicStack/asyncpg/pull/846

**UPD:**
the issue with proposal: https://github.com/sqlalchemy/sqlalchemy/issues/9608

### Description
Added optional parameter `name_func` to `AsyncAdapt_asyncpg_connection` class which will call on the `self._connection.prepare()` function and populate a unique name.

so in general instead this

```python

from uuid import uuid4

from asyncpg import Connection

class CConnection(Connection):
    def _get_unique_id(self, prefix: str) -> str:
        return f'__asyncpg_{prefix}_{uuid4()}__'

engine = create_async_engine(...,
    connect_args={
        'connection_class': CConnection,
    },
)

```

would be enough

```python
from uuid import uuid4

engine = create_async_engine(...,
    connect_args={
        'name_func': lambda:  f'__asyncpg_{uuid4()}__',
    },
)

```

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

-->

This pull request is:

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

**Have a nice day!**

Fixes: #9608
Closes: #9607
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9607
Pull-request-sha: b4bc8d3e57ab095a26112830ad4bea36083454e3

Change-Id: Icd753366cba166b8a60d1c8566377ec8335cd828

2 years agoMerge "add deterministic imv returning ordering using sentinel columns" into main
mike bayer [Fri, 21 Apr 2023 16:51:19 +0000 (16:51 +0000)] 
Merge "add deterministic imv returning ordering using sentinel columns" into main

2 years agoadd deterministic imv returning ordering using sentinel columns
Mike Bayer [Wed, 5 Apr 2023 15:58:52 +0000 (11:58 -0400)] 
add deterministic imv returning ordering using sentinel columns

Repaired a major shortcoming which was identified in the
:ref:`engine_insertmanyvalues` performance optimization feature first
introduced in the 2.0 series. This was a continuation of the change in
2.0.9 which disabled the SQL Server version of the feature due to a
reliance in the ORM on apparent row ordering that is not guaranteed to take
place. The fix applies new logic to all "insertmanyvalues" operations,
which takes effect when a new parameter
:paramref:`_dml.Insert.returning.sort_by_parameter_order` on the
:meth:`_dml.Insert.returning` or :meth:`_dml.UpdateBase.return_defaults`
methods, that through a combination of alternate SQL forms, direct
correspondence of client side parameters, and in some cases downgrading to
running row-at-a-time, will apply sorting to each batch of returned rows
using correspondence to primary key or other unique values in each row
which can be correlated to the input data.

Performance impact is expected to be minimal as nearly all common primary
key scenarios are suitable for parameter-ordered batching to be
achieved for all backends other than SQLite, while "row-at-a-time"
mode operates with a bare minimum of Python overhead compared to the very
heavyweight approaches used in the 1.x series. For SQLite, there is no
difference in performance when "row-at-a-time" mode is used.

It's anticipated that with an efficient "row-at-a-time" INSERT with
RETURNING batching capability, the "insertmanyvalues" feature can be later
be more easily generalized to third party backends that include RETURNING
support but not necessarily easy ways to guarantee a correspondence
with parameter order.

Fixes: #9618
References: #9603
Change-Id: I1d79353f5f19638f752936ba1c35e4dc235a8b7c

2 years agoMerge "try to omit unnecessary cols for ORM bulk insert + returning" into main
mike bayer [Fri, 21 Apr 2023 15:28:43 +0000 (15:28 +0000)] 
Merge "try to omit unnecessary cols for ORM bulk insert + returning" into main

2 years agotry to omit unnecessary cols for ORM bulk insert + returning
Mike Bayer [Fri, 21 Apr 2023 13:48:04 +0000 (09:48 -0400)] 
try to omit unnecessary cols for ORM bulk insert + returning

Fixed bug in ORM bulk insert feature where additional unnecessary columns
would be rendered in the INSERT statement if RETURNING of individual
columns were requested.

Fixes: #9685
Change-Id: Ibf5f06ab017215c7c9bd8850c3a006f73fe78c68

2 years agoMerge "Add intersection method to Range class" into main
mike bayer [Fri, 21 Apr 2023 12:35:01 +0000 (12:35 +0000)] 
Merge "Add intersection method to Range class" into main

2 years agoFix `RowMapping`'s `Mapping` type to reflect that it supports `Column`s or strings
Andy Freeland [Thu, 20 Apr 2023 17:41:39 +0000 (13:41 -0400)] 
Fix `RowMapping`'s `Mapping` type to reflect that it supports `Column`s or strings

### Description

I ran into this originally in sqlalchemy2-stubs: https://github.com/sqlalchemy/sqlalchemy2-stubs/pull/251, where `RowMapping` only supported string keys according to the type hints. I ran into a similar issue here upgrading our application where because `RowMapping` subclassed `Mapping[str, Any]`, `Row._mapping.get()` would fail to typecheck when used with `Column` objects.

This patch adds a test to verify that `Row._mapping.get()` continues to work with both strings and `Column`s, though it doesn't look like mypy checks types in the tests.

Fixes #9644.

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

-->

This pull request is:

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

**Have a nice day!**

Closes: #9643
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9643
Pull-request-sha: 6c33fe534cf457d6b5c73f4830a64880830f0f56

Change-Id: I1009c6defff109d73f13a9e8c51641009e6a79e2

2 years agofix typo ('resemblence' -> 'resemblance') (#9674)
Tim Stewart [Thu, 20 Apr 2023 17:42:02 +0000 (12:42 -0500)] 
fix typo ('resemblence' -> 'resemblance') (#9674)

2 years agoBump pypa/cibuildwheel from 2.12.1 to 2.12.3 (#9672)
dependabot[bot] [Wed, 19 Apr 2023 17:55:06 +0000 (19:55 +0200)] 
Bump pypa/cibuildwheel from 2.12.1 to 2.12.3 (#9672)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.12.1 to 2.12.3.
- [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.12.1...v2.12.3)

---
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>
2 years agoMerge "Define type hints for remaining column operators" into main
Federico Caselli [Tue, 18 Apr 2023 19:38:18 +0000 (19:38 +0000)] 
Merge "Define type hints for remaining column operators" into main

2 years agoDefine type hints for remaining column operators
Martijn Pieters [Mon, 17 Apr 2023 23:24:57 +0000 (19:24 -0400)] 
Define type hints for remaining column operators

Added typing information for recently added operators
:meth:`.ColumnOperators.icontains`, :meth:`.ColumnOperators.istartswith`,
:meth:`.ColumnOperators.iendswith`, and bitwise operators
:meth:`.ColumnOperators.bitwise_and`, :meth:`.ColumnOperators.bitwise_or`,
:meth:`.ColumnOperators.bitwise_xor`, :meth:`.ColumnOperators.bitwise_not`,
:meth:`.ColumnOperators.bitwise_lshift`
:meth:`.ColumnOperators.bitwise_rshift`. Pull request courtesy Martijn
Pieters.

Fixes: #9650
Closes: #9652
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9652
Pull-request-sha: 005c56848af8cff6bb19f71541873027f141eb6e

Change-Id: I2fa06eb42ce668df9d9c760d233906f87484dd12

2 years agoimprove return type for QueryableAttribute.and_()
Mike Bayer [Tue, 18 Apr 2023 13:42:50 +0000 (09:42 -0400)] 
improve return type for QueryableAttribute.and_()

Fixed typing issue where :meth:`_orm.PropComparator.and_` expressions would
not be correctly typed inside of loader options such as
:func:`_orm.selectinload`.

Fixes: #9669
Change-Id: I874cb22c004e0a24f2b7f530fda542de2c4c6d3b

2 years agoMerge "apply criteria options from top-level core-only statement" into main
mike bayer [Mon, 17 Apr 2023 21:26:26 +0000 (21:26 +0000)] 
Merge "apply criteria options from top-level core-only statement" into main

2 years agoapply criteria options from top-level core-only statement
Mike Bayer [Mon, 17 Apr 2023 17:46:12 +0000 (13:46 -0400)] 
apply criteria options from top-level core-only statement

Made an improvement to the :func:`_orm.with_loader_criteria` loader option
to allow it to be indicated in the :meth:`.Executable.options` method of a
top-level statement that is not itself an ORM statement. Examples include
:func:`_sql.select` that's embedded in compound statements such as
:func:`_sql.union`, within an :meth:`_dml.Insert.from_select` construct, as
well as within CTE expressions that are not ORM related at the top level.
Improved propagation of :func:`_orm.with_loader_criteria` within
ORM enabled UPDATE and DELETE statements as well.

Fixes: #9635
Change-Id: I088ad91929dc797c06f292f5dc547d48ffb30430

2 years agodont assume _compile_options are present
Mike Bayer [Mon, 17 Apr 2023 14:16:35 +0000 (10:16 -0400)] 
dont assume _compile_options are present

Fixed bug where various ORM-specific getters such as
:attr:`.ORMExecuteState.is_column_load`,
:attr:`.ORMExecuteState.is_relationship_load`,
:attr:`.ORMExecuteState.loader_strategy_path` etc. would throw an
``AttributeError`` if the SQL statement itself were a "compound select"
such as a UNION.

Fixes: #9634
Change-Id: Ia37df5d6f89d6534d69237dcab294bd849ece28b

2 years agorun docs sync
Mike Bayer [Mon, 17 Apr 2023 13:18:23 +0000 (09:18 -0400)] 
run docs sync

this is needed due to previous commit f7bfa04bcae1e9baf

Change-Id: I7fa397707a018455a2c96b62704dfd506742b0cd

2 years agoclarify get_isolation_level() excludes AUTOCOMMIT
Mike Bayer [Mon, 17 Apr 2023 12:22:49 +0000 (08:22 -0400)] 
clarify get_isolation_level() excludes AUTOCOMMIT

I thought this was documented but apparently not.

Fixes: #9658
Change-Id: I93fad12c159c599ffdbab1aff586b49e8c92a6e4

2 years agoAdd intersection method to Range class
Yurii Karabas [Fri, 14 Apr 2023 17:37:40 +0000 (13:37 -0400)] 
Add intersection method to Range class

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

### Description
Fixes: #9509
<!-- Describe your changes in detail -->

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

-->

This pull request is:

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

**Have a nice day!**

Closes: #9510
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9510
Pull-request-sha: 596648e7989327eef1807057519b2295b48f1adf

Change-Id: I7b527edda09eb78dee6948edd4d49b00ea437011

2 years agoRemove mypy dataclass reference (#9651)
Federico Caselli [Fri, 14 Apr 2023 17:34:21 +0000 (19:34 +0200)] 
Remove mypy dataclass reference (#9651)

2 years agoMerge "Add additional seealso to schema reflect parameters" into main
mike bayer [Thu, 13 Apr 2023 21:05:47 +0000 (21:05 +0000)] 
Merge "Add additional seealso to schema reflect parameters" into main

2 years agoMerge "Add pool creation functions" into main
mike bayer [Thu, 13 Apr 2023 21:05:19 +0000 (21:05 +0000)] 
Merge "Add pool creation functions" into main

2 years agoAdd additional seealso to schema reflect parameters
Federico Caselli [Thu, 6 Apr 2023 20:53:28 +0000 (22:53 +0200)] 
Add additional seealso to schema reflect parameters

References: #9606
Change-Id: I1213f881621a80eb78a2db84e53150437144f26c

2 years agoMerge "Remove old versionadded and versionchanged" into main
mike bayer [Wed, 12 Apr 2023 23:41:19 +0000 (23:41 +0000)] 
Merge "Remove old versionadded and versionchanged" into main

2 years agoMerge "establish column_property and query_expression as readonly from a dc perspecti...
Federico Caselli [Wed, 12 Apr 2023 21:21:36 +0000 (21:21 +0000)] 
Merge "establish column_property and query_expression as readonly from a dc perspective" into main

2 years agoRemove old versionadded and versionchanged
Federico Caselli [Wed, 12 Apr 2023 21:17:38 +0000 (23:17 +0200)] 
Remove old versionadded and versionchanged

Removed versionadded and versionchanged for version prior to 1.2 since they
are no longer useful.

Change-Id: I5c53d1188bc5fec3ab4be39ef761650ed8fa6d3e

2 years agoAdding typing to Postgres dialect file.
John Clow [Wed, 12 Apr 2023 06:34:58 +0000 (02:34 -0400)] 
Adding typing to Postgres dialect file.

Adding typing information for various parameters for Postgres types (in accordance to the docs).

This pull request is:

- [x] A documentation / typographical 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: #9594
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9594
Pull-request-sha: c7e39a219108f9e81ad22c008a664b62f09f9d5f

Change-Id: I91b377c246c728885a99df297de7a8933835c540

2 years agoAdd pool creation functions
Federico Caselli [Fri, 7 Apr 2023 18:12:04 +0000 (20:12 +0200)] 
Add pool creation functions

Added :func:`_sa.create_pool_from_url` and
:func:`_asyncio.create_async_pool_from_url` to create
a :class:`_pool.Pool` instance from an input url passed as string
or :class:`_sa.URL`.

Fixes: #9613
Change-Id: Icd8aa3f2849e6fd1bc5341114f3ef8d216a2c543

2 years agoestablish column_property and query_expression as readonly from a dc perspective
Mike Bayer [Mon, 10 Apr 2023 16:56:47 +0000 (12:56 -0400)] 
establish column_property and query_expression as readonly from a dc perspective

Fixed bug in ORM Declarative Dataclasses where the
:func:`_orm.queryable_attribute` and :func:`_orm.column_property`
constructs, which are documented as read-only constructs in the context of
a Declarative mapping, could not be used with a
:class:`_orm.MappedAsDataclass` class without adding ``init=False``, which
in the case of :func:`_orm.queryable_attribute` was not possible as no
``init`` parameter was included. These constructs have been modified from a
dataclass perspective to be assumed to be "read only", setting
``init=False`` by default and no longer including them in the pep-681
constructor. The dataclass parameters for :func:`_orm.column_property`
``init``, ``default``, ``default_factory``, ``kw_only`` are now deprecated;
these fields don't apply to :func:`_orm.column_property` as used in a
Declarative dataclasses configuration where the construct would be
read-only. Also added read-specific parameter
:paramref:`_orm.queryable_attribute.compare` to
:func:`_orm.queryable_attribute`; :paramref:`_orm.queryable_attribute.repr`
was already present.

Added missing :paramref:`_orm.mapped_column.active_history` parameter
to :func:`_orm.mapped_column` construct.

Fixes: #9628
Change-Id: I2ab44d6b763b20410bd1ebb5ac949a6d223f1ce2

2 years agomake the linter happy
Federico Caselli [Wed, 12 Apr 2023 18:51:41 +0000 (20:51 +0200)] 
make the linter happy

Change-Id: I7104c7cb081c9b61894958cef5d0b4707474994d

2 years agoFix Association Proxy example
Gord Thompson [Tue, 11 Apr 2023 19:56:37 +0000 (13:56 -0600)] 
Fix Association Proxy example

Minor corrections to "Simplifying Association
Objects" example in the Association Proxy docs.

https: //github.com/sqlalchemy/sqlalchemy/discussions/9636
Change-Id: Ib433cf78b149d330889d947bbaf2b03c9dd87c29

2 years agorestore mypy to released version 1.2.0
Mike Bayer [Mon, 10 Apr 2023 20:01:25 +0000 (16:01 -0400)] 
restore mypy to released version 1.2.0

Change-Id: Ice0233af37f387747a283ef2d2293aaa194b52d9

2 years agoMerge "include declared_directive as a declared_attr" into main
mike bayer [Mon, 10 Apr 2023 17:56:30 +0000 (17:56 +0000)] 
Merge "include declared_directive as a declared_attr" into main

2 years agoMerge "mypy 1.2 has fixed dataclass descriptor support" into main
mike bayer [Mon, 10 Apr 2023 17:49:13 +0000 (17:49 +0000)] 
Merge "mypy 1.2 has fixed dataclass descriptor support" into main

2 years agoinclude declared_directive as a declared_attr
Mike Bayer [Mon, 10 Apr 2023 14:28:44 +0000 (10:28 -0400)] 
include declared_directive as a declared_attr

Fixed issue where the :meth:`_orm.declared_attr.directive` modifier was not
correctly honored for subclasses when applied to the ``__mapper_args__``
special method name, as opposed to direct use of
:class:`_orm.declared_attr`. The two constructs should have identical
runtime behaviors.

Fixes: #9625
Change-Id: I0dfe9e73bb45f70dbebc8e94ce280ad3b52e867f

2 years agoMerge "optimize exec defaults a bit" into main
mike bayer [Sun, 9 Apr 2023 14:32:09 +0000 (14:32 +0000)] 
Merge "optimize exec defaults a bit" into main

2 years agoMerge "Fix reflection of long expressions in postgresql" into main
mike bayer [Sun, 9 Apr 2023 14:19:36 +0000 (14:19 +0000)] 
Merge "Fix reflection of long expressions in postgresql" into main