]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agoremove theme altogether sphinx_mini_build
Mike Bayer [Sun, 23 Apr 2023 17:22:02 +0000 (13:22 -0400)] 
remove theme altogether

Change-Id: Iaa5d1ac26007451c09d6982c06d8ad6ed22d30bc

2 years agoremove all labels and links that are no longer locatable
Mike Bayer [Sun, 23 Apr 2023 16:54:45 +0000 (12:54 -0400)] 
remove all labels and links that are no longer locatable

Change-Id: Ic975b8c20bc297d3a04dde0bed143783ae951cd4

2 years agofix broken links
Mike Bayer [Sun, 23 Apr 2023 16:28:28 +0000 (12:28 -0400)] 
fix broken links

Change-Id: Ic5419636b52b57f551e5eec3b1468149ddabfd61

2 years agominimum doc build
Mike Bayer [Sun, 23 Apr 2023 16:21:59 +0000 (12:21 -0400)] 
minimum doc build

remove  a huge amount of docs so we can run without extensions
and send Sphinx a bug report that version 6.x has become unaccepably
memory hogging

Change-Id: I17b6265187a7901b4714130dd303fccb1d86bb0e

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

2 years agooptimize exec defaults a bit
Mike Bayer [Sun, 9 Apr 2023 01:16:58 +0000 (21:16 -0400)] 
optimize exec defaults a bit

since I am probably using this for the new "sentinel" thing,
clean up this code, reduce codepaths and inline a bit

Change-Id: I9cb312828e3bc23636f6db794b169f1acc4ebae3

2 years agofix pg ENUM issues
Mike Bayer [Sat, 8 Apr 2023 22:43:31 +0000 (18:43 -0400)] 
fix pg ENUM issues

Restored the :paramref:`_postgresql.ENUM.name` parameter as optional in the
signature for :class:`_postgresql.ENUM`, as this is chosen automatically
from a given pep-435 ``Enum`` type.

Fixed issue where the comparison for :class:`_postgresql.ENUM` against a
plain string would cast that right-hand side type as VARCHAR, which due to
more explicit casting added to dialects such as asyncpg would produce a
PostgreSQL type mismatch error.

Fixes: #9611
Fixes: #9621
Change-Id: If095544cd1a52016ad2e7cfa2d70c919a94e79c1

2 years agoupdate for mypy 1.2.0
Mike Bayer [Sat, 8 Apr 2023 18:22:33 +0000 (14:22 -0400)] 
update for mypy 1.2.0

Change-Id: I6a46046af5b6ed484b470057761e77b485e2e061

2 years agoMerge "generalize the SQL Server test from #9603" into main
mike bayer [Sat, 8 Apr 2023 04:51:22 +0000 (04:51 +0000)] 
Merge "generalize the SQL Server test from #9603" into main

2 years agowalk back SQL Server language a bit re: insertmanyvalues
Mike Bayer [Sat, 8 Apr 2023 03:31:55 +0000 (23:31 -0400)] 
walk back SQL Server language a bit re: insertmanyvalues

In #9618 we both can look to re-enable insertmanyvalues
for SQL Server, and also likely *disable* its use for the
ORM unit of work specifically, since that's really where the
only problem is, and it will likely be for all dialects,
not just SQL Server.   An approach using sentinel columns will
be rolled out for the unit of work use case.

Change-Id: I3358e30839491769db95b4ac042a661271df3929
References: #9618
References: #9603

2 years agoFix typo in the doc for `mapped_column` (#9612)
Harshit Doshi [Fri, 7 Apr 2023 22:02:23 +0000 (03:32 +0530)] 
Fix typo in the doc for `mapped_column` (#9612)

I found an extremely and probably insignificant typo in the doc for `mapped_column` while actually trying to use and understand it for my project and have fixed it here.

The typo was for a "for" which was instead mentioned as "or".

2 years agoUpdate data_select.rst (#9616)
Chris [Fri, 7 Apr 2023 20:07:54 +0000 (16:07 -0400)] 
Update data_select.rst (#9616)

Fix literal text in example

2 years agoFix reflection of long expressions in postgresql
Federico Caselli [Fri, 7 Apr 2023 18:35:37 +0000 (20:35 +0200)] 
Fix reflection of long expressions in postgresql

Fixed issue that prevented reflection of expression based indexes
with long expressions in PostgreSQL. The expression where erroneously
truncated to the identifier length (that's 63 bytes by default).

Fixes: #9615
Change-Id: I50727b0699e08fa25f10f3c94dcf8b79534bfb75

2 years agogeneralize the SQL Server test from #9603
Mike Bayer [Fri, 7 Apr 2023 17:28:54 +0000 (13:28 -0400)] 
generalize the SQL Server test from #9603

Change-Id: If6f2efd7cd443593a8e7ca06109e51cfd07ed020

2 years agoFix typos in PostgreSQL dialect’s DOMAIN docs (#9601)
Jens Tröger [Thu, 6 Apr 2023 20:55:33 +0000 (06:55 +1000)] 
Fix typos in PostgreSQL dialect’s DOMAIN docs (#9601)

2 years agoVersion 2.0.10 placeholder
Mike Bayer [Wed, 5 Apr 2023 23:37:03 +0000 (19:37 -0400)] 
Version 2.0.10 placeholder

2 years ago- 2.0.9 rel_2_0_9
Mike Bayer [Wed, 5 Apr 2023 23:28:29 +0000 (19:28 -0400)] 
- 2.0.9

2 years agorevise changelog for #9586
Mike Bayer [Wed, 5 Apr 2023 23:27:10 +0000 (19:27 -0400)] 
revise changelog for #9586

this would be misleading due to #9603 disabling insertmanyvalues
across the board.

Change-Id: I0e746e13f8ad054207790644cb43eba101dde30c

2 years agoturn off use_insertmanyvalues for SQL Server
Mike Bayer [Wed, 5 Apr 2023 16:59:13 +0000 (12:59 -0400)] 
turn off use_insertmanyvalues for SQL Server

we will keep trying to find workarounds, however this
patch is the "turn it off" patch

Due to a critical bug identified in SQL Server, the SQLAlchemy
"insertmanyvalues" feature which allows fast INSERT of many rows while also
supporting RETURNING unfortunately needs to be disabled for SQL Server. SQL
Server is apparently unable to guarantee that the order of rows inserted
matches the order in which they are sent back by OUTPUT inserted when
table-valued rows are used with INSERT in conjunction with OUTPUT inserted.
We are trying to see if Microsoft is able to confirm this undocumented
behavior however there is no known workaround, other than it's not safe to
use table-valued expressions with OUTPUT inserted for now.

Fixes: #9603
Change-Id: I4b932fb8774390bbdf4e870a1f6cfe9a78c4b105

2 years agomypy 1.2 has fixed dataclass descriptor support
Mike Bayer [Tue, 4 Apr 2023 14:02:30 +0000 (10:02 -0400)] 
mypy 1.2 has fixed dataclass descriptor support

Currently using the PR for test.

Change-Id: Idc4c475587f5151ef79046d24ca3ac274c2cb2ca
References: https://github.com/python/mypy/issues/14868

2 years agoconsider aliased mappers in cycles also
Mike Bayer [Sun, 2 Apr 2023 18:24:32 +0000 (14:24 -0400)] 
consider aliased mappers in cycles also

Fixed endless loop which could occur when using "relationship to aliased
class" feature and also indicating a recursive eager loader such as
``lazy="selectinload"`` in the loader, in combination with another eager
loader on the opposite side. The check for cycles has been fixed to include
aliased class relationships.

Fixes: #9590
Change-Id: I8d340882f040ff9289c209bedd8fbdfd7186f944

2 years agoMerge "Added ``row_number`` as reserved word in MariaDb." into main
mike bayer [Sun, 2 Apr 2023 17:22:20 +0000 (17:22 +0000)] 
Merge "Added ``row_number`` as reserved word in MariaDb." into main

2 years agoAdded ``row_number`` as reserved word in MariaDb.
Federico Caselli [Sun, 2 Apr 2023 08:33:27 +0000 (10:33 +0200)] 
Added ``row_number`` as reserved word in MariaDb.

Fixes: #9588
References: #9585
Change-Id: Ic6668311ea488339023d7aab1a186f8465131fd8

2 years agofavor fast_executemany over insertmanyvalues when set
Mike Bayer [Sun, 2 Apr 2023 04:01:47 +0000 (00:01 -0400)] 
favor fast_executemany over insertmanyvalues when set

Changed the bulk INSERT strategy used for SQL Server "executemany" with
pyodbc when ``fast_executemany`` is set to ``True`` by using
``fast_executemany`` / ``cursor.executemany()`` for bulk INSERT that does
not include RETURNING, restoring the same behavior as was used in
SQLAlchemy 1.4 when this parameter is set. For INSERT statements that use
RETURNING, the "insertmanyvalues" strategy continues to be used as it is
the only current strategy that supports RETURNING with bulk INSERT.

Previously, SQLAlchemy 2.0 would use "insertmanyvalues" for all INSERT
statements when ``use_insertmanyvalues`` was left at its default of
``False``, ignoring if ``fast_executemany`` was set.

New performance details from end users have shown that ``fast_executemany``
is still much faster for very large datasets as it uses ODBC commands that
can receive all rows in a single round trip, allowing for much larger
datasizes than the batches that can be sent by the current
"insertmanyvalues" strategy.

Fixes: #9586
Change-Id: I85955a10ba77c26cdc0c22e362a827d7aaef2852

2 years agoVersion 2.0.9 placeholder
Mike Bayer [Fri, 31 Mar 2023 18:48:00 +0000 (14:48 -0400)] 
Version 2.0.9 placeholder

2 years ago- 2.0.8 rel_2_0_8
Mike Bayer [Fri, 31 Mar 2023 18:04:38 +0000 (14:04 -0400)] 
- 2.0.8

2 years agodoc and changelog fixes
Mike Bayer [Fri, 31 Mar 2023 18:03:54 +0000 (14:03 -0400)] 
doc and changelog fixes

Change-Id: I611684872ea34d05cc5d81ade0813676df00e03f

2 years agoWrap dataclass exceptions clarifying origin
Federico Caselli [Wed, 29 Mar 2023 22:25:39 +0000 (00:25 +0200)] 
Wrap dataclass exceptions clarifying origin

Exceptions such as ``TypeError`` and ``ValueError`` raised by Python
dataclasses when making use of the :class:`_orm.MappedAsDataclass` mixin
class or :meth:`_orm.registry.mapped_as_dataclass` decorator are now
wrapped within an :class:`.InvalidRequestError` wrapper along with
informative context about the error message, referring to the Python
dataclasses documentation as the authoritative source of background
information on the cause of the exception.

Fixes: #9563
Change-Id: I25652485b91c4ee8cf112b91aae8f9041061a8bd

2 years agoMerge "skip anno-only mixin columns that are overridden on subclasses" into main
mike bayer [Fri, 31 Mar 2023 13:55:28 +0000 (13:55 +0000)] 
Merge "skip anno-only mixin columns that are overridden on subclasses" into main

2 years agoMerge "copy deferred attributes for mapped_column" into main
mike bayer [Fri, 31 Mar 2023 13:52:16 +0000 (13:52 +0000)] 
Merge "copy deferred attributes for mapped_column" into main

2 years agoMerge "Add missing methods to OrderedSet." into main
mike bayer [Fri, 31 Mar 2023 13:51:47 +0000 (13:51 +0000)] 
Merge "Add missing methods to OrderedSet." into main

2 years agoMerge "warn for DC mixin / abstract fields that are not on a dataclass" into main
mike bayer [Fri, 31 Mar 2023 13:48:41 +0000 (13:48 +0000)] 
Merge "warn for DC mixin / abstract fields that are not on a dataclass" into main

2 years agoclarify the Uuid datatype handles Python uuid objects by default
Mike Bayer [Fri, 31 Mar 2023 12:46:53 +0000 (08:46 -0400)] 
clarify the Uuid datatype handles Python uuid objects by default

Change-Id: I28147bfb4eb0762e9482d4f38bc1d89355152ad4
References: #9573

2 years agowarn for DC mixin / abstract fields that are not on a dataclass
Mike Bayer [Thu, 30 Mar 2023 18:48:39 +0000 (14:48 -0400)] 
warn for DC mixin / abstract fields that are not on a dataclass

Fields that are declared on Declarative Mixins and then combined with
classes that make use of :class:`_orm.MappedAsDataclass`, where those mixin
fields are not themselves part of a dataclass, now emit a deprecation
warning as these fields will be ignored in a future release, as Python
dataclasses behavior is to ignore these fields. Type checkers will not see
these fields under pep-681.

Fixes: #9350
Change-Id: Ie0a0ac0f0bb58d1c2aae13b4a8dcd0439a4f5477

2 years agoAdd missing methods to OrderedSet.
Federico Caselli [Tue, 14 Mar 2023 22:17:07 +0000 (23:17 +0100)] 
Add missing methods to OrderedSet.

Implemented missing method ``copy`` and ``pop`` in OrderedSet class.

Fixes: #9487
Change-Id: I1d2278b64939b44422e9d5857ec7d345fff53997

2 years agoMerge "assign correct typing to deferred(), query_property()" into main
mike bayer [Thu, 30 Mar 2023 19:17:00 +0000 (19:17 +0000)] 
Merge "assign correct typing to deferred(), query_property()" into main

2 years agocopy deferred attributes for mapped_column
Mike Bayer [Thu, 30 Mar 2023 16:55:45 +0000 (12:55 -0400)] 
copy deferred attributes for mapped_column

Fixed issue where the :func:`_orm.mapped_column` construct would raise an
internal error if used on a Declarative mixin and included the
:paramref:`_orm.mapped_column.deferred` parameter.

Fixes: #9550
Change-Id: I0cc5ec4910656abc9a3fb7b7b60880256cd7c61e

2 years agoMerge "Minor improvements in collections.pyx" into main
mike bayer [Thu, 30 Mar 2023 18:56:10 +0000 (18:56 +0000)] 
Merge "Minor improvements in collections.pyx" into main

2 years agoassign correct typing to deferred(), query_property()
Mike Bayer [Thu, 30 Mar 2023 16:44:49 +0000 (12:44 -0400)] 
assign correct typing to deferred(), query_property()

Fixed typing for :func:`_orm.deferred` and :func:`_orm.query_expression`
to work correctly with 2.0 style mappings.

Fixes: #9536
Change-Id: Idb88c0a11b7896093234b3cc31595f64b552cba0

2 years agoMerge "warn for all unmapped expressions" into main
mike bayer [Thu, 30 Mar 2023 14:17:30 +0000 (14:17 +0000)] 
Merge "warn for all unmapped expressions" into main

2 years agoadd mypy issue 13856 to bug reporting template
Mike Bayer [Thu, 30 Mar 2023 14:14:23 +0000 (10:14 -0400)] 
add mypy issue 13856 to bug reporting template

Change-Id: Ie25810bfb188794858ba39e246a72b06c484e474
References: #9567

2 years agoskip anno-only mixin columns that are overridden on subclasses
Mike Bayer [Thu, 30 Mar 2023 13:00:49 +0000 (09:00 -0400)] 
skip anno-only mixin columns that are overridden on subclasses

Fixed issue where an annotation-only :class:`_orm.Mapped` directive could
not be used in a Declarative mixin class, without that attribute attempting
to take effect for single- or joined-inheritance subclasses of mapped
classes that had already mapped that attribute on a superclass, producing
conflicting column errors and/or warnings.

Fixes: #9564
Change-Id: I0f92be2ae98a8c45afce3e06d0a7cc61c19a96f4

2 years agoMerge "disable raise sql for the delete cascade" into main
mike bayer [Wed, 29 Mar 2023 13:15:55 +0000 (13:15 +0000)] 
Merge "disable raise sql for the delete cascade" into main

2 years agoMerge "Improve from_select typing" into main
mike bayer [Tue, 28 Mar 2023 22:05:23 +0000 (22:05 +0000)] 
Merge "Improve from_select typing" into main

2 years agodisable raise sql for the delete cascade
Mike Bayer [Sun, 26 Mar 2023 16:30:35 +0000 (12:30 -0400)] 
disable raise sql for the delete cascade

Towards maintaining consistency with unit-of-work changes made for
:ticket:`5984` and :ticket:`8862`, both of which disable "lazy='raise'"
handling within :class:`_orm.Session` processes that aren't triggered by
attribute access, the :meth:`_orm.Session.delete` method will now also
disable "lazy='raise'" handling when it traverses relationship paths in
order to process the "delete" and "delete-orphan" cascade rules.
Previously, there was no easy way to generically call
:meth:`_orm.Session.delete` on an object that had "lazy='raise'" set up
such that only the necessary relationships would be loaded. As
"lazy='raise'" is primarily intended to catch SQL loading that emits on
attribute access, :meth:`_orm.Session.delete` is now made to behave like
other :class:`_orm.Session` methods including :meth:`_orm.Session.merge` as
well as :meth:`_orm.Session.flush` along with autoflush.

Fixes: #9549
Change-Id: Ie049e66ce2bd35900eae4af0e9b795633303ca63

2 years agoImprove from_select typing
Federico Caselli [Mon, 27 Mar 2023 20:03:44 +0000 (22:03 +0200)] 
Improve from_select typing

Properly type :paramref:`_dml.Insert.from_select.names` to accept
a list of string or columns or mapped attributes.
Fixes: #9514
Change-Id: I2a3396454e79bd2113fc3d57d1252a2e6d141310

2 years agoMerge "check for recursion with container types" into main
mike bayer [Mon, 27 Mar 2023 23:34:46 +0000 (23:34 +0000)] 
Merge "check for recursion with container types" into main

2 years agoMerge "support DeclarativeBase for versioned history example" into main
mike bayer [Mon, 27 Mar 2023 23:33:02 +0000 (23:33 +0000)] 
Merge "support DeclarativeBase for versioned history example" into main

2 years agocheck for recursion with container types
Mike Bayer [Mon, 27 Mar 2023 14:19:32 +0000 (10:19 -0400)] 
check for recursion with container types

Fixed issue in ORM Annotated Declarative where using a recursive type (e.g.
using a nested Dict type) would result in a recursion overflow in the ORM's
annotation resolution logic, even if this datatype were not necessary to
map the column.

Fixes: #9553
Change-Id: Ied99dc0d47276c6e9c23fa9df5fc65f7736d65cf

2 years agoFix creating zero length char with MySQL dialect
J. Nick Koston [Sun, 26 Mar 2023 02:00:25 +0000 (22:00 -0400)] 
Fix creating zero length char with MySQL dialect

Fixed issue where string datatypes such as :class:`.CHAR`,
:class:`.VARCHAR`, :class:`.TEXT`, as well as binary :class:`.BLOB`, could
not be produced with an explicit length of zero, which has special meaning
for MySQL. Pull request courtesy J. Nick Koston.

Fixes: #9544
Closes: #9543
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9543
Pull-request-sha: dc17fc3e93f0ba90881c4efb06016ddf83c7af8b

Change-Id: I96925d45f16887f5dfd68a5d4f9284b3abc46d25

2 years agosupport DeclarativeBase for versioned history example
Mike Bayer [Mon, 27 Mar 2023 13:48:58 +0000 (09:48 -0400)] 
support DeclarativeBase for versioned history example

Fixed issue in "versioned history" example where using a declarative base
that is derived from :class:`_orm.DeclarativeBase` would fail to be mapped.
Additionally, repaired the given test suite so that the documented
instructions for running the example using Python unittest now work again.

Change-Id: I164a5b8dbdd01e3d815eb356f7b7cadf226ca296
References: #9546

2 years agodocs: 📚 fix duplicate word typo (#9539)
Tom Wolfskämpf [Sat, 25 Mar 2023 17:45:37 +0000 (17:45 +0000)] 
docs: ðŸ“š fix duplicate word typo (#9539)

2 years agoMerge "automatically provision hstore for pg13+" into main
mike bayer [Sat, 25 Mar 2023 13:51:12 +0000 (13:51 +0000)] 
Merge "automatically provision hstore for pg13+" into main

2 years agowarn for all unmapped expressions
Mike Bayer [Fri, 24 Mar 2023 15:11:54 +0000 (11:11 -0400)] 
warn for all unmapped expressions

Expanded the warning emitted when a plain :func:`_sql.column` object is
present in a Declarative mapping to include any arbitrary SQL expression
that is not declared within an appropriate property type such as
:func:`_orm.column_property`, :func:`_orm.deferred`, etc. These attributes
are otherwise not mapped at all and remain unchanged within the class
dictionary. As it seems likely that such an expression is usually not
what's intended, this case now warns for all such otherwise ignored
expressions, rather than just the :func:`_sql.column` case.

Fixes: #9537
Change-Id: Ic4ca7a071a28adf4ea8680690025d927522a0805

2 years agoMerge "use clone, not constructor, in BindParameter.render_literal_execute()" into...
mike bayer [Wed, 22 Mar 2023 23:54:57 +0000 (23:54 +0000)] 
Merge "use clone, not constructor, in BindParameter.render_literal_execute()" into main

2 years agouse clone, not constructor, in BindParameter.render_literal_execute()
Mike Bayer [Wed, 22 Mar 2023 15:56:04 +0000 (11:56 -0400)] 
use clone, not constructor, in BindParameter.render_literal_execute()

Fixed issue where the :meth:`_sql.BindParameter.render_literal_execute`
method would fail when called on a parameter that also had ORM annotations
associated with it. In practice, this would be observed as a failure of SQL
compilation when using some combinations of a dialect that uses "FETCH
FIRST" such as Oracle along with a :class:`_sql.Select` construct that uses
:meth:`_sql.Select.limit`, within some ORM contexts, including if the
statement were embedded within a relationship primaryjoin expression.

Fixes: #9526
Change-Id: I2f512b6760a90293d274e60b06a891f10b276ecc

2 years agoMerge "return None for no parententity on Proxy" into main
mike bayer [Wed, 22 Mar 2023 15:29:41 +0000 (15:29 +0000)] 
Merge "return None for no parententity on Proxy" into main

2 years agofix update in nested_sets example
Mike Bayer [Tue, 21 Mar 2023 18:43:46 +0000 (14:43 -0400)] 
fix update in nested_sets example

Fixes: #9520
Change-Id: I3dbf62bd9b70fb226cf7c641719df8ac53ec1427

2 years agoadd tip that reflection is not necessary for an existing database
Mike Bayer [Tue, 21 Mar 2023 17:40:36 +0000 (13:40 -0400)] 
add tip that reflection is not necessary for an existing database

a new user spent many days misled by this paragraph thinking
they were required to use reflection for an existing database.

Change-Id: I4c6757b931481db7a8d4202334382143e1491935