]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agoMerge "Improve array_agg and Array processing" into main
mike bayer [Sat, 17 Sep 2022 14:55:04 +0000 (14:55 +0000)] 
Merge "Improve array_agg and Array processing" into main

2 years agoremove obtuse section about "bundled bind parameters"
Mike Bayer [Sat, 17 Sep 2022 14:18:56 +0000 (10:18 -0400)] 
remove obtuse section about "bundled bind parameters"

Just looking for basics on insert in the first pages
of the tutorial I see this weird detour into something that
nobody ever uses and definitely isn't going to make sense
to the people I see complaining about our docs on twitter,
remove this.   the tutorial probably needs a big sweep
for wordy obtuse things.  the userbase is changing and
we really have a lot of brand-new-to-programming types coming
in.

Change-Id: I3bb11f0399e55edbb8f874e7eb63c40616b04e8b

2 years agoImprove array_agg and Array processing
Federico Caselli [Sat, 17 Sep 2022 11:12:35 +0000 (13:12 +0200)] 
Improve array_agg and Array processing

The :class:`_functions.array_agg` will now set the array dimensions to 1.
Improved :class:`_types.ARRAY` processing to accept ``None`` values as
value of a multi-array.

Fixes: #7083
Change-Id: Iafec4f77fde9719ccc7c8535bf6235dbfbc62102

2 years agoMerge "Ignore max_overflow when pool_size is 0" into main
mike bayer [Fri, 16 Sep 2022 22:28:45 +0000 (22:28 +0000)] 
Merge "Ignore max_overflow when pool_size is 0" into main

2 years agoMerge "Support GROUP BY ROLLUP on MySql/MariaDB" into main
mike bayer [Fri, 16 Sep 2022 22:27:14 +0000 (22:27 +0000)] 
Merge "Support GROUP BY ROLLUP on MySql/MariaDB" into main

2 years agoMerge "catch exception for system_views also" into main
mike bayer [Fri, 16 Sep 2022 22:26:25 +0000 (22:26 +0000)] 
Merge "catch exception for system_views also" into main

2 years agofix documentation typos
Federico Caselli [Fri, 16 Sep 2022 21:50:47 +0000 (23:50 +0200)] 
fix documentation typos

Closes #8527
Change-Id: I0354f3953075fa35a84b09ad45fd850d8889c992

(cherry picked from commit 02b1ed522038cbe90f9548c49ce41c29fc68032c)

2 years agoIgnore max_overflow when pool_size is 0
Federico Caselli [Thu, 15 Sep 2022 20:42:08 +0000 (22:42 +0200)] 
Ignore max_overflow when pool_size is 0

The :class:`_pool.QueuePool` now ignores ``max_overflow`` when
``pool_size=0``, properly making the pool unlimited in all cases.

Fixes: #8523
Change-Id: Ifc32eb47a281c4b3acf357352f07b9b8a73d1b6f

2 years agoMerge "Improved usage of ``asyncio.shield()``" into main
Federico Caselli [Thu, 15 Sep 2022 20:18:58 +0000 (20:18 +0000)] 
Merge "Improved usage of ``asyncio.shield()``" into main

2 years agoMerge "Use ``;`` instead of ``select 1`` to ping PostgreSQL" into main
Federico Caselli [Thu, 15 Sep 2022 20:18:39 +0000 (20:18 +0000)] 
Merge "Use ``;`` instead of ``select 1`` to ping PostgreSQL" into main

2 years agoMerge "Add type awareness to evaluator" into main
mike bayer [Thu, 15 Sep 2022 15:30:23 +0000 (15:30 +0000)] 
Merge "Add type awareness to evaluator" into main

2 years agoUse ``;`` instead of ``select 1`` to ping PostgreSQL
Federico Caselli [Tue, 13 Sep 2022 19:47:50 +0000 (21:47 +0200)] 
Use ``;`` instead of ``select 1`` to ping PostgreSQL

Fixes: #8491
Change-Id: I941d2a3cf92e5609e2045a53cec94522340951db

2 years agoImproved usage of ``asyncio.shield()``
Federico Caselli [Tue, 13 Sep 2022 19:23:12 +0000 (21:23 +0200)] 
Improved usage of ``asyncio.shield()``

Fixes: #8516
Change-Id: Ifd8f5e5f42d9fbcd5b8d00bddc81ff6be690a75e

2 years agocatch exception for system_views also
Mike Bayer [Thu, 15 Sep 2022 12:42:34 +0000 (08:42 -0400)] 
catch exception for system_views also

Fixed yet another regression in SQL Server isolation level fetch (see
:ticket:`8231`, :ticket:`8475`), this time with "Microsoft Dynamics CRM
Database via Azure Active Directory", which apparently lacks the
``system_views`` view entirely. Error catching has been extended that under
no circumstances will this method ever fail, provided database connectivity
is present.

Fixes: #8525
Change-Id: I76a429e3329926069a0367d2e77ca1124b9a059d

2 years agoadd missing doc for mariadb-connector
Mike Bayer [Thu, 15 Sep 2022 03:09:08 +0000 (23:09 -0400)] 
add missing doc for mariadb-connector

this module was never indexed.   kind of a major oversight

Change-Id: I4389a2ca3900edc70130fbae66195605a5704362

2 years agoBump pypa/cibuildwheel from 2.9.0 to 2.10.0 (#8517)
dependabot[bot] [Tue, 13 Sep 2022 19:03:28 +0000 (21:03 +0200)] 
Bump pypa/cibuildwheel from 2.9.0 to 2.10.0 (#8517)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.9.0 to 2.10.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.9.0...v2.10.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoAdd type awareness to evaluator
Mike Bayer [Tue, 13 Sep 2022 15:00:46 +0000 (11:00 -0400)] 
Add type awareness to evaluator

Fixed regression where using ORM update() with synchronize_session='fetch'
would fail due to the use of evaluators that are now used to determine the
in-Python value for expressions in the the SET clause when refreshing
objects; if the evaluators make use of math operators against non-numeric
values such as PostgreSQL JSONB, the non-evaluable condition would fail to
be detected correctly. The evaluator now limits the use of math mutation
operators to numeric types only, with the exception of "+" that continues
to work for strings as well. SQLAlchemy 2.0 may alter this further by
fetching the SET values completely rather than using evaluation.

Fixes: #8507
Change-Id: Icf7120ccbf4266499df6bb3e05159c9f50971d69

2 years agoSupport GROUP BY ROLLUP on MySql/MariaDB
Federico Caselli [Fri, 9 Sep 2022 19:29:53 +0000 (21:29 +0200)] 
Support GROUP BY ROLLUP on MySql/MariaDB

The ``ROLLUP`` function will now correctly render ``WITH ROLLUP`` on
MySql and MariaDB, allowing the use of group by rollup with these
backend.

Fixes: #8503
Change-Id: I9289af3a39ca667a2f0f84f73346ebd4b091fedd

2 years agoMerge "additional de-stringify pass for unions" into main
mike bayer [Thu, 8 Sep 2022 19:00:08 +0000 (19:00 +0000)] 
Merge "additional de-stringify pass for unions" into main

2 years agoMerge "implement icontains, istartswith, iendswith operators" into main
mike bayer [Thu, 8 Sep 2022 18:19:46 +0000 (18:19 +0000)] 
Merge "implement icontains, istartswith, iendswith operators" into main

2 years agoadditional de-stringify pass for unions
Mike Bayer [Thu, 8 Sep 2022 17:19:08 +0000 (13:19 -0400)] 
additional de-stringify pass for unions

the change in c3cfee5b00a40790c18d took out
a pass for de-stringify that broke some un-tested cases
for Optional with future annotations mode.   Adding tests
for this revealed that this was a subset of
a more general case where Union is presented
with ForwardRefs inside of it matching up within the type
map, which wasn't working before either, fixed that as well with
an additional de-stringify for elements within the Union.

Fixes: #8478
Change-Id: I8804cf6c67f14d10804584e1cddd2cfaa2376654

2 years agolimit sqlite UPDATE..FROM to 3.33.0
Mike Bayer [Thu, 8 Sep 2022 17:46:41 +0000 (13:46 -0400)] 
limit sqlite UPDATE..FROM to 3.33.0

Change-Id: I25ad8a9d6f657f85dd216b4d624f711225ef9f04
References: https://www.sqlite.org/lang_update.html

2 years agoMerge "enable UPDATE..FROM for SQLite" into main
mike bayer [Thu, 8 Sep 2022 16:31:35 +0000 (16:31 +0000)] 
Merge "enable UPDATE..FROM for SQLite" into main

2 years agoimplement icontains, istartswith, iendswith operators
Matias Martinez Rebori [Wed, 7 Sep 2022 16:36:06 +0000 (12:36 -0400)] 
implement icontains, istartswith, iendswith operators

Added long-requested case-insensitive string operators
:meth:`_sql.ColumnOperators.icontains`,
:meth:`_sql.ColumnOperators.istartswith`,
:meth:`_sql.ColumnOperators.iendswith`, which produce case-insensitive
LIKE compositions (using ILIKE on PostgreSQL, and the LOWER() function on
all other backends) to complement the existing LIKE composition operators
:meth:`_sql.ColumnOperators.contains`,
:meth:`_sql.ColumnOperators.startswith`, etc. Huge thanks to Matias
Martinez Rebori for their meticulous and complete efforts in implementing
these new methods.

Fixes: #3482
Closes: #8496
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8496
Pull-request-sha: 7287e2c436959fac4fef022f359fcc73d1528211

Change-Id: I9fcdd603716218067547cc92a2b07bd02a2c366b

2 years agoenable UPDATE..FROM for SQLite
Mike Bayer [Wed, 7 Sep 2022 21:13:23 +0000 (17:13 -0400)] 
enable UPDATE..FROM for SQLite

The SQLite dialect now supports UPDATE..FROM syntax, for UPDATE statements
that may refer to additional tables within the WHERE criteria of the
statement without the need to use subqueries. This syntax is invoked
automatically when using the :class:`_dml.Update` construct when more than
one table or other entity or selectable is used.

Fixes: #7185
Change-Id: I27e94ace9ff761cc45e652fa1abff8cd1f42fec5

2 years agoadd docs for session.get()
Mike Bayer [Wed, 7 Sep 2022 23:00:31 +0000 (19:00 -0400)] 
add docs for session.get()

also use the term "primary key" a bit more

Change-Id: Ib654b30a9d06a2aeed019b4754db920afe05d774
References: https://twitter.com/encthenet/status/1567644850471989248

2 years agocherry-pick changelog update for 1.4.42
Mike Bayer [Wed, 7 Sep 2022 00:58:38 +0000 (20:58 -0400)] 
cherry-pick changelog update for 1.4.42

2 years agocherry-pick changelog from 1.4.41
Mike Bayer [Wed, 7 Sep 2022 00:58:37 +0000 (20:58 -0400)] 
cherry-pick changelog from 1.4.41

2 years agochangelog fixes
Mike Bayer [Wed, 7 Sep 2022 00:49:15 +0000 (20:49 -0400)] 
changelog fixes

Change-Id: Ie0217dfea32d08abf7934950b1e1b381e612bb56
(cherry picked from commit 1ce530c0b25bc8a7d09b97bf300aba55d2603892)

2 years agoImprove compiled extension detection
Federico Caselli [Sun, 4 Sep 2022 19:44:46 +0000 (21:44 +0200)] 
Improve compiled extension detection

Ensure that all cython extension are imported by the compied detection logic.
This is required since cython extensions moduels are marked as optional
in the install, so it's possible that only some of them are compiled.
The extensions are enabled only if all of them are correctly compiled

Change-Id: I355cbac06f5c7a47d35661f42ebab3b0156c1965

2 years agoexpand @ sign warning to include other characters
Mike Bayer [Sat, 3 Sep 2022 15:14:27 +0000 (11:14 -0400)] 
expand @ sign warning to include other characters

Change-Id: Ied7d81ddda11f77cabc8cdc11723c95ba05a708c

2 years agoMerge "Fix Azure Synapse connection error" into main
mike bayer [Fri, 2 Sep 2022 23:21:14 +0000 (23:21 +0000)] 
Merge "Fix Azure Synapse connection error" into main

2 years agoMerge "Detection of PEP 604 union syntax." into main
mike bayer [Fri, 2 Sep 2022 14:07:26 +0000 (14:07 +0000)] 
Merge "Detection of PEP 604 union syntax." into main

2 years agoFix Azure Synapse connection error
Gord Thompson [Thu, 1 Sep 2022 17:10:20 +0000 (11:10 -0600)] 
Fix Azure Synapse connection error

Fixed regression caused by the fix for :ticket:`8231` released in 1.4.40
where connection would fail if the user does not have permission to query
the dm_exec_sessions or dm_pdw_nodes_exec_sessions system view when trying
to determine the current transaction isolation level.

Fixes: #8475
Change-Id: Ie2bcda92f2ef2d12360ddda47eb6e896313c71f2

2 years agoDetection of PEP 604 union syntax.
Peter Schutt [Thu, 1 Sep 2022 23:11:40 +0000 (19:11 -0400)] 
Detection of PEP 604 union syntax.

### Description

Fixes #8478

Handle `UnionType` as arguments to `Mapped`, e.g., `Mapped[str | None]`:

- adds `utils.typing.is_optional_union()` used to detect if a column should be nullable.
- adds `"UnionType"` to `utils.typing.is_optional()` names.
- uses `get_origin()` in `utils.typing.is_origin_of()` as `UnionType` has no `__origin__` attribute.
- tests with runtime type and postponed annotations and guard the tests running with `compat.py310`.

### 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: #8479
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8479
Pull-request-sha: 12417654822272c5847e684c53677f665553ef0e

Change-Id: Ib3248043dd4a97324ac592c048385006536b2d49

2 years agoMark extension modules as optional
Federico Caselli [Mon, 29 Aug 2022 22:26:49 +0000 (00:26 +0200)] 
Mark extension modules as optional

This greatly simplifies the setup.py file and makes it compatible with
setuptools 64+ change to editable install.

Change-Id: I16a776b175bcf67e26f4bbb8f80b1b473f585e2a

2 years agorun update_subclass anytime we add new clslevel dispatch
Mike Bayer [Wed, 31 Aug 2022 15:07:23 +0000 (11:07 -0400)] 
run update_subclass anytime we add new clslevel dispatch

Fixed event listening issue where event listeners added to a superclass
would be lost if a subclass were created which then had its own listeners
associated. The practical example is that of the :class:`.sessionmaker`
class created after events have been associated with the
:class:`_orm.Session` class.

Fixes: #8467
Change-Id: I9bdba8769147e30110a09900d4a577e833ac3af9

2 years agoFix doc snippet (#8414)
Daniel Dương [Tue, 30 Aug 2022 21:05:25 +0000 (18:05 -0300)] 
Fix doc snippet (#8414)

2 years agoMerge "include TableClause.schema in cache key" into main
mike bayer [Tue, 30 Aug 2022 17:11:03 +0000 (17:11 +0000)] 
Merge "include TableClause.schema in cache key" into main

2 years agoinclude TableClause.schema in cache key
Mike Bayer [Tue, 30 Aug 2022 14:47:24 +0000 (10:47 -0400)] 
include TableClause.schema in cache key

Fixed issue where use of the :func:`_sql.table` construct, passing a string
for the :paramref:`_sql.table.schema` parameter, would fail to take the
"schema" string into account when producing a cache key, thus leading to
caching collisions if multiple, same-named :func:`_sql.table` constructs
with different schemas were used.

Fixes: #8441
Change-Id: Ic4b55b3e8ec53b4c88ba112691bdf60ea1d4c448

2 years agoimplement event for merge/load=False for mutable state setup
Mike Bayer [Tue, 30 Aug 2022 14:25:47 +0000 (10:25 -0400)] 
implement event for merge/load=False for mutable state setup

Fixed issue in :mod:`sqlalchemy.ext.mutable` extension where collection
links to the parent object would be lost if the object were merged with
:meth:`.Session.merge` while also passing :paramref:`.Session.merge.load`
as False.

The event added here is currently private for expediency, but
is acceptable to become a public event at some point.

Fixes: #8446
Change-Id: I9e5b9f1f5a0c5a9781f51635d5e57b1134c9e866

2 years agoapply consistent ORM mutable notes for all mutable SQL types
Mike Bayer [Tue, 30 Aug 2022 13:50:03 +0000 (09:50 -0400)] 
apply consistent ORM mutable notes for all mutable SQL types

in
https://github.com/sqlalchemy/sqlalchemy/discussions/8447
I was surprised that we didnt have any notes about using Mutable
for ARRAY classes, since we have them for HSTORE and JSON.

Add a consistent topic box for these so we have something to
point towards.

Change-Id: Idfa1b2cbee67024545f4fa299e4c875075ec7d3f

2 years agoMerge "Use cibuildwheel to create wheels" into main
Federico Caselli [Tue, 30 Aug 2022 13:13:59 +0000 (13:13 +0000)] 
Merge "Use cibuildwheel to create wheels" into main

2 years agoMerge "refine ruleset to determine when poly adaption should be used" into main
mike bayer [Tue, 30 Aug 2022 04:52:57 +0000 (04:52 +0000)] 
Merge "refine ruleset to determine when poly adaption should be used" into main

2 years agorefine ruleset to determine when poly adaption should be used
Mike Bayer [Mon, 29 Aug 2022 14:43:36 +0000 (10:43 -0400)] 
refine ruleset to determine when poly adaption should be used

Fixed regression appearing in the 1.4 series where a joined-inheritance
query placed as a subquery within an enclosing query for that same entity
would fail to render the JOIN correctly for the inner query. The issue
manifested in two different ways prior and subsequent to version 1.4.18
(related issue #6595), in one case rendering JOIN twice, in the other
losing the JOIN entirely. To resolve, the conditions under which
"polymorphic loading" are applied have been scaled back to not be invoked
for simple joined inheritance queries.

Fixes: #8456
Change-Id: Ie4332fadb1dfc670cd31d098a6586a9f6976bcf7

2 years agorestore test concurrency try 2
Federico Caselli [Mon, 29 Aug 2022 18:57:01 +0000 (20:57 +0200)] 
restore test concurrency try 2

Change-Id: I54730f9683a1de3f1379ca8d2a1cab8c485e7bcc

2 years agoUse cibuildwheel to create wheels
Trevor Gross [Wed, 24 Aug 2022 10:32:31 +0000 (06:32 -0400)] 
Use cibuildwheel to create wheels

Using cibuildwheel the following wheels are created:
- windows x64 and x84
- macos x64 and arm
- linux x64 and arm on manylinux and mosulinux (for alpine)
- create a pure python wheel (for pypy and other archs)

Fixes: #6702
Fixes: #7607
Closes: #7992
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7992
Pull-request-sha: 61d5e24e5b76c97db73aa2507af7f5c2d3a948fa

Change-Id: If0c0b353766e0b61d421789d619eb2b940c08ad0

2 years agoRevert "restore test concurrency"
Mike Bayer [Mon, 29 Aug 2022 16:56:27 +0000 (12:56 -0400)] 
Revert "restore test concurrency"

This reverts commit fa30381444803af15eb128eabd7dd49609716f01.

2 years agorestore test concurrency
Federico Caselli [Sat, 27 Aug 2022 12:48:02 +0000 (14:48 +0200)] 
restore test concurrency

Change-Id: I118ce933d1fd1203e97ef2959ee6def595f1fc0b

2 years agoMerge "try out greenlet / cython on py311" into main
mike bayer [Fri, 26 Aug 2022 19:43:46 +0000 (19:43 +0000)] 
Merge "try out greenlet / cython on py311" into main

2 years agotry out greenlet / cython on py311
Mike Bayer [Thu, 25 Aug 2022 18:05:16 +0000 (14:05 -0400)] 
try out greenlet / cython on py311

I've updated jenkins to see what happens

Change-Id: If71b3f6da98dacd21419e8ece2395bc5fd20d133

2 years agorun github pipeline on python 3.11
Federico Caselli [Thu, 25 Aug 2022 18:46:46 +0000 (20:46 +0200)] 
run github pipeline on python 3.11

Change-Id: Id1f13e71b803ead2cebfcca02720ab3d6504f57c

2 years agoMerge "integrate connection.terminate() for supporting dialects" into main
mike bayer [Wed, 24 Aug 2022 18:08:17 +0000 (18:08 +0000)] 
Merge "integrate connection.terminate() for supporting dialects" into main

2 years agofix mock issue in pool test
Mike Bayer [Wed, 24 Aug 2022 17:06:09 +0000 (13:06 -0400)] 
fix mock issue in pool test

Due to the change for #5648 in ad14471bc99c2fb2315d3333a95dd,
the mock in test_recycle_pool_no_race needs to implement
an empty handle_error dispatcher.

the exception was in a thread so did not interrupt the
test suite:

File "/home/classic/dev/sqlalchemy/lib/sqlalchemy/engine/base.py", line 2059, in _handle_dbapi_exception
      for fn in self.dialect.dispatch.handle_error:
  TypeError: 'Mock' object is not iterable

Change-Id: I764357c48aa1bf53a572d8ee24c89a7463505092

2 years agointegrate connection.terminate() for supporting dialects
Mike Bayer [Tue, 23 Aug 2022 13:28:06 +0000 (09:28 -0400)] 
integrate connection.terminate() for supporting dialects

Integrated support for asyncpg's ``terminate()`` method call for cases
where the connection pool is recycling a possibly timed-out connection,
where a connection is being garbage collected that wasn't gracefully
closed, as well as when the connection has been invalidated. This allows
asyncpg to abandon the connection without waiting for a response that may
incur long timeouts.

Fixes: #8419
Change-Id: Ia575af779d5733b483a72dff3690b8bbbad2bb05

2 years agoMerge "include mssql_clustered dialect_options when reflecting - issue #8288" into...
mike bayer [Wed, 24 Aug 2022 17:00:25 +0000 (17:00 +0000)] 
Merge "include mssql_clustered dialect_options when reflecting - issue #8288" into main

2 years agoinclude mssql_clustered dialect_options when reflecting - issue #8288
John Lennox [Sun, 21 Aug 2022 05:35:44 +0000 (01:35 -0400)] 
include mssql_clustered dialect_options when reflecting - issue #8288

Implemented reflection of the "clustered index" flag ``mssql_clustered``
for the SQL Server dialect. Pull request courtesy John Lennox.

Fixes: #8288
Closes: #8289
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8289
Pull-request-sha: 1bb57352e3e31d8fb7de69ab5e60e5464949f640

Change-Id: Ife367066328f9e47ad823e4098647964a18e21e8

2 years agorepair sphinx undoc-members directive
Mike Bayer [Mon, 22 Aug 2022 19:29:31 +0000 (15:29 -0400)] 
repair sphinx undoc-members directive

"undoc-members" : False means *include* undocumented
members, it seems.

Change-Id: I90faf9b3ce3a94448b6522f7ad9946426f762900

2 years agomore function adjustments
Mike Bayer [Mon, 22 Aug 2022 17:55:08 +0000 (13:55 -0400)] 
more function adjustments

the inherited-members feature works very poorly
and inconsistently in sphinx.  just dont use it here as it
refuses to exclude ColumnOperators methods

Change-Id: Ic50865c9901e7225a99ff7f33454da15ff91b12f

2 years agoreformat functions.rst; document coalsce
Mike Bayer [Mon, 22 Aug 2022 17:43:59 +0000 (13:43 -0400)] 
reformat functions.rst; document coalsce

this file was all over the place autodocumenting all the
contents of functions.py with no regards to the heading
paragraph which seemed to be introducing the generic functions.
Use specific autoclass/autofunc docs as automodule is generally
unworkable.

Add missing docstring for coalesce function.

Fixes: #8415
Change-Id: I4c37e6153282ce99b9f5d674f6e802c25ef536e1

2 years agoMerge "support create/drop events for all CREATE/DROP" into main
mike bayer [Mon, 22 Aug 2022 13:30:36 +0000 (13:30 +0000)] 
Merge "support create/drop events for all CREATE/DROP" into main

2 years agoColumn._copy() duplicates "user defined" nullable state exactly
Mike Bayer [Sun, 21 Aug 2022 15:58:20 +0000 (11:58 -0400)] 
Column._copy() duplicates "user defined" nullable state exactly

To accommodate how mapped_column() works, after many
attempts to get this working it became clear that _copy()
should just transfer "nullable" state exactly as it was,
including the state where .nullable was set but user_defined_nullable
remains at not user set.

additionally, added a similar step to _merge() that was needed
to preserve the nullability behavior when Identity is present.

server / client default objects are not copied within column._copy()
and this should be fixed.

Fixes: #8410
Change-Id: Ib09df52b71f3e58e67e9f19b893d40a6cc4eec5c

2 years agosupport create/drop events for all CREATE/DROP
Mike Bayer [Tue, 16 Aug 2022 14:44:48 +0000 (10:44 -0400)] 
support create/drop events for all CREATE/DROP

Implemented the DDL event hooks :meth:`.DDLEvents.before_create`,
:meth:`.DDLEvents.after_create`, :meth:`.DDLEvents.before_drop`,
:meth:`.DDLEvents.after_drop` for all :class:`.SchemaItem` objects that
include a distinct CREATE or DROP step, when that step is invoked as a
distinct SQL statement, including for :class:`.ForeignKeyConstraint`,
:class:`.Sequence`, :class:`.Index`, and PostgreSQL's
:class:`_postgresql.ENUM`.

Fixes: #8394
Change-Id: Iee6274984e794f50103451a04d089641d6ac443a

2 years agoadd missing abstract concrete base changelog
Mike Bayer [Fri, 19 Aug 2022 16:30:35 +0000 (12:30 -0400)] 
add missing abstract concrete base changelog

Was missing from commit d0abdbe247dc82db51aa0af3d31b0510

Fixes: #8403
Change-Id: Ic4d9116236072ce495b5bef2671515a24d04eca2

2 years agoremove narrative "reconstructor" document
Mike Bayer [Fri, 19 Aug 2022 15:12:41 +0000 (11:12 -0400)] 
remove narrative "reconstructor" document

this event hook is not commonly used and this page does not
fit into the current narrative very well.  We should possibly
write a new paragraph regarding how instances load
at some point though the best place to put it is not clear.

2 years agoremove notes re: current pymssql DBAPI features
Mike Bayer [Fri, 19 Aug 2022 14:16:34 +0000 (10:16 -0400)] 
remove notes re: current pymssql DBAPI features

Fixes: #8337
Change-Id: Ib0c107bb386489dcb6d1683f29d0a9574dd96f1e

2 years agofix some inaccuracies in with_variant doc
Mike Bayer [Fri, 19 Aug 2022 13:49:25 +0000 (09:49 -0400)] 
fix some inaccuracies in with_variant doc

* the table wont create on mysql/mariadb b.c. user_name had
  no length
* "utf-8" is not recognized by mysql/mariadb, use "utf8"
* mysql or mariadb name match is determined by the URL, not the
  actual DB that is detected (I know I made it work that way but
  I forgot)
* for the 1.4 backport only, will remove the "mariadb" part
  as we dont support that API, #8408

Fixes: #8408
Change-Id: I5b0a58a3f94a3450631e2405bd07d0a77599ae26

2 years agoMerge "improve abstractconcretebase" into main
mike bayer [Thu, 18 Aug 2022 18:36:53 +0000 (18:36 +0000)] 
Merge "improve abstractconcretebase" into main

2 years agoset old declarative docs as orphan
Mike Bayer [Thu, 18 Aug 2022 17:56:50 +0000 (13:56 -0400)] 
set old declarative docs as orphan

these otherwise show up in the sidebar where they are
confusing

Change-Id: Ic7bdcd31207a135e2805241928ca2379a8189565

2 years agoimprove abstractconcretebase
Mike Bayer [Wed, 17 Aug 2022 21:47:19 +0000 (17:47 -0400)] 
improve abstractconcretebase

try to limit the attributes on the base and set up wpoly
etc so that things still work the way we want.

It seems like I've tried this in the past before so not sure
if this is actually working or if there are problems.   it needs
a little more strictness on how you set up your base since
attributes are no longer implicit.  So, it seems like perhaps
the new behavior should be on a flag or something like
"strict_attributes=True", something like that, so that nothing
breaks for existing users and we can slowly deal with the new
way being a little bit less worse than the old way.

Fixes: #8403
Change-Id: Ic9652d9a0b024d649807aaf3505e67173e7dc3b9

2 years agomore abstractconcretebase clarity
Mike Bayer [Thu, 18 Aug 2022 15:54:04 +0000 (11:54 -0400)] 
more abstractconcretebase clarity

Change-Id: I9ddb6b1a2e0c0be1fe355a7ea714d0e16aa93b47

2 years agoremove nonsensical note
Mike Bayer [Thu, 18 Aug 2022 15:29:25 +0000 (11:29 -0400)] 
remove nonsensical note

this note is not factually incorrect but it makes no sense
why this would be in the middle of the abstract concrete doc

Change-Id: Icd67d9d9a93ee72714bf85d8d5ca39c0af61f356

2 years agoMerge "validate mapped collection key is loaded" into main
mike bayer [Wed, 17 Aug 2022 22:26:05 +0000 (22:26 +0000)] 
Merge "validate mapped collection key is loaded" into main

2 years agoMerge "fill out all distinguising fields for AliasedInsp" into main
mike bayer [Wed, 17 Aug 2022 22:23:57 +0000 (22:23 +0000)] 
Merge "fill out all distinguising fields for AliasedInsp" into main

2 years agoMerge "refine transfer of cached ORM options for selectin, lazy" into main
mike bayer [Wed, 17 Aug 2022 18:42:04 +0000 (18:42 +0000)] 
Merge "refine transfer of cached ORM options for selectin, lazy" into main

2 years agovalidate mapped collection key is loaded
Mike Bayer [Tue, 9 Aug 2022 17:31:14 +0000 (13:31 -0400)] 
validate mapped collection key is loaded

Changed the attribute access method used by
:func:`_orm.attribute_mapped_collection` and
:func:`_orm.column_mapped_collection`, used when populating the dictionary,
to assert that the data value on the object to be used as the dictionary
key is actually present, and is not instead using "None" due to the
attribute never being actually assigned. This is used to prevent a
mis-population of None for a key when assigning via a backref where the
"key" attribute on the object is not yet assigned.

As the failure mode here is a transitory condition that is not typically
persisted to the database, and is easy to produce via the constructor of
the class based on the order in which parameters are assigned, it is very
possible that many applications include this behavior already which is
silently passed over. To accommodate for applications where this error is
now raised, a new parameter
:paramref:`_orm.attribute_mapped_collection.ignore_unpopulated_attribute`
is also added to both :func:`_orm.attribute_mapped_collection` and
:func:`_orm.column_mapped_collection` that instead causes the erroneous
backref assignment to be skipped.

Fixes: #8372
Change-Id: I85bf4af405adfefe6386f0f2f8cef22537d95912

2 years agoMerge "restore Connectable and other changes for oslo.db" into main
mike bayer [Wed, 17 Aug 2022 17:39:14 +0000 (17:39 +0000)] 
Merge "restore Connectable and other changes for oslo.db" into main

2 years agoMerge "Propagate key for collection events" into main
mike bayer [Wed, 17 Aug 2022 17:37:53 +0000 (17:37 +0000)] 
Merge "Propagate key for collection events" into main

2 years agorefine transfer of cached ORM options for selectin, lazy
Mike Bayer [Tue, 16 Aug 2022 18:25:12 +0000 (14:25 -0400)] 
refine transfer of cached ORM options for selectin, lazy

Fixed issue involving :func:`_orm.with_loader_criteria` where a closure
variable used as bound parameter value within the lambda would not carry
forward correctly into additional relationship loaders such as
:func:`_orm.selectinload` and :func:`_orm.lazyload` after the statement
were cached, using the stale originally-cached value instead.

This change brings forth a good refinement where we finally realize
we shouldn't be testing every ORM option with lots of switches, we
just let the option itself be given "here is your uncached version,
you are cached, tell us what to do!".   the current decision is
that strategy loader options used the cached in all cases as they
always have, with_loader_criteria uses the uncached, because the
uncached will have been invoked with new closure state that we
definitely need.   The only
edge that might not work is if with_loader_criteria referenced
an entity that is local to the query, namely a specific AliasedInsp,
however that's not a documented case for this.  if we had to do that,
then we perhaps would introduce a more complex reconcilation
logic, and this would also give us the hook to do that.

Fixes: #8399
Change-Id: Ided8e2123915131e3f11cf6b06d773039e73797a

2 years agoMerge "JSONPATH type can be used in casts in PostgreSQL" into main
mike bayer [Wed, 17 Aug 2022 17:11:50 +0000 (17:11 +0000)] 
Merge "JSONPATH type can be used in casts in PostgreSQL" into main

2 years agofill out all distinguising fields for AliasedInsp
Mike Bayer [Wed, 17 Aug 2022 17:06:51 +0000 (13:06 -0400)] 
fill out all distinguising fields for AliasedInsp

Hardened the cache key strategy for the :func:`_orm.aliased` and
:func:`_orm.with_polymorphic` constructs. While no issue involving actual
statements being cached can easily be demonstrated (if at all), these two
constructs were not including enough of what makes them unique in their
cache keys for caching on the aliased construct alone to be accurate.

Fixes: #8401
Change-Id: I13d14985b6965f398edd9494601d8ae89ac641f2

2 years agoJSONPATH type can be used in casts in PostgreSQL
Federico Caselli [Tue, 2 Aug 2022 10:27:57 +0000 (12:27 +0200)] 
JSONPATH type can be used in casts in PostgreSQL

Introduced the type :class:`_postgresql.JSONPATH` that can be used
in cast expressions. This is required by some PostgreSQL dialects
when using functions such as ``jsonb_path_exists`` or
``jsonb_path_match`` that accept a ``jsonpath`` as input.

Fixes: #8216
Change-Id: I3e7337eab91680cab1604e1f3058854a0a19c5be

2 years agoMerge "Support comments on MSSQL" into main
mike bayer [Wed, 17 Aug 2022 15:33:24 +0000 (15:33 +0000)] 
Merge "Support comments on MSSQL" into main

2 years agoremove erroneous note about future metadata
Mike Bayer [Wed, 17 Aug 2022 13:17:33 +0000 (09:17 -0400)] 
remove erroneous note about future metadata

this change was already applied

Change-Id: I24cfdc1912b77f98ae6d0f3865cabd223553fc79

2 years agoPropagate key for collection events
Mike Bayer [Wed, 10 Aug 2022 14:53:11 +0000 (10:53 -0400)] 
Propagate key for collection events

Added new parameter :paramref:`_orm.AttributeEvents.include_key`, which
will include the dictionary or list key for operations such as
``__setitem__()`` (e.g. ``obj[key] = value``) and ``__delitem__()`` (e.g.
``del obj[key]``), using a new keyword parameter "key" or "keys", depending
on event, e.g. :paramref:`_orm.AttributeEvents.append.key`,
:paramref:`_orm.AttributeEvents.bulk_replace.keys`. This allows event
handlers to take into account the key that was passed to the operation and
is of particular importance for dictionary operations working with
:class:`_orm.MappedCollection`.

Fixes: #8375
Change-Id: Icc472f7c28848f94e15c94a399cc13a88782e1e4

2 years agorestore Connectable and other changes for oslo.db
Mike Bayer [Fri, 12 Aug 2022 22:35:14 +0000 (18:35 -0400)] 
restore Connectable and other changes for oslo.db

at this point oslo.db should be passing tests however
they seem to be importing "Connectable", which we had
temporarily removed, it's now a different kind of object
but restore it to the engine import space which seems
to be where they're pulling it from to see if oslo.db
can run some tests now.

Change-Id: I52cb5ad82b00eec12004eeeb571c4eb8efa5ced2

2 years agoAdd support for Partitioning and Sample pages on mysql
RamonWill [Tue, 25 Aug 2020 00:17:19 +0000 (20:17 -0400)] 
Add support for Partitioning and Sample pages on mysql

Add support for Partitioning and Sample pages on MySQL and MariaDB
reflected options.
The options are stored in the table dialect options dictionary, so
the following keyword need to be prefixed with ``mysql_`` or ``mariadb_``
depending on the backend.
Supported options are:

* ``stats_sample_pages``
* ``partition_by``
* ``partitions``
* ``subpartition_by``

These options are also reflected when loading a table from database,
and will populate the table :attr:`_schema.Table.dialect_options`.
Pull request courtesy of Ramon Will.

Fixes: #4038
Closes: #5536
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5536
Pull-request-sha: f8852cabe15c9a91de85d27980988051f7a1306d

Change-Id: I69b60576532af04c725c998e9e8fec6e2040b149

2 years agoreorg bulk persistence into a separate module
Mike Bayer [Thu, 11 Aug 2022 14:20:49 +0000 (10:20 -0400)] 
reorg bulk persistence into a separate module

This restores persistence.py to only functions that are used
by unitofwork.py, and all the "bulk" stuff gets its own
module bulk_persistence.py.  Also fixes up the ORM context
class hierarchy for bulk.

This is all ahead of the ORM-insert changes coming in, so that
the later review can be about logic and not about reorganization.

Change-Id: I035896e9e77fcece866d246edf30097cccad0182

2 years agoSupport comments on MSSQL
Daniel Hall [Sat, 30 Jul 2022 19:12:20 +0000 (15:12 -0400)] 
Support comments on MSSQL

Added support table and column comments on MSSQL when
creating a table. Added support for reflecting table comments.
Thanks to Daniel Hall for the help in this pull request.

Fixes: #7844
Closes: #8225
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8225
Pull-request-sha: 540f4eb6395f9feed4b4240e3d22f539021948e9

Change-Id: I69f48c6dda4e00ec3d82fdeff13f3df9d735b7b0

2 years agodoc fixes
Mike Bayer [Wed, 10 Aug 2022 16:40:17 +0000 (12:40 -0400)] 
doc fixes

* fixed erroneous use of mapped_column() in m2m relationship Table
* Fill in full imports for some relationship examples that had
  partial imports; examples that have no imports, leave empty for now
* converted joined/single inh mappings to annotated style
* We have a problem with @declared_attr in that the error message
  is wrong if the mapped_column() returned doesnt have a type, and/or
  mapped_column() with @declared_attr doesnt use the annotation
* fix thing where sphinx with undoc-members global setting seems to
  no longer tolerate ":attribute:" entries in autodoc classes, which
  is fine we can document the annotations now
* Fix mapper params in inheritance to be on Mapper
* add missing changelog file for instances remove

Change-Id: I9b70b25a320d8122fade68bc4d1f82f8b72b26f3

2 years agoimprove names for datatypes section
Mike Bayer [Tue, 9 Aug 2022 13:50:57 +0000 (09:50 -0400)] 
improve names for datatypes section

Continuing along #8362, if we look at the document here without
"this is the same text I've read for 14 years", we begin to see
that the title "Column and Data types" makes no sense at all,
is there a "column type" and a "Data type"?  I guess what I was
thinking at that time is that a type can be placed on a
Column, or it can be used whenever you have, you know, "data".
The phrase "SQL expression" wasn't discovered yet.

"SQL Datatype" is not spectacular but at least it's one term.
the new intro then is focused on the hierarchy layout so let's
name it that.

not amazing, but better than the duplicate name that made
no sense before.

Fixes: #8362
Change-Id: Iab37ef5605ec55f30284ac9a98bf7246f736675d

2 years agoimprove typing intro
Mike Bayer [Mon, 8 Aug 2022 18:50:29 +0000 (14:50 -0400)] 
improve typing intro

Fixes: #8362
Change-Id: I38aa1727e94c50a9f06bd75d57ea1ca1cfffd2f3

2 years agocherry-pick changelog update for 1.4.41
Mike Bayer [Mon, 8 Aug 2022 16:16:26 +0000 (12:16 -0400)] 
cherry-pick changelog update for 1.4.41

2 years agocherry-pick changelog from 1.4.40
Mike Bayer [Mon, 8 Aug 2022 16:16:25 +0000 (12:16 -0400)] 
cherry-pick changelog from 1.4.40

2 years agorepair doc warnings
Mike Bayer [Mon, 8 Aug 2022 16:08:30 +0000 (12:08 -0400)] 
repair doc warnings

Change-Id: I446105028539a34da90d6b8ae4812965cc398ee5
(cherry picked from commit c539ee35229b03d61f2a10e9f5ab613201341e19)

2 years agodeep compare CTEs before considering them conflicting
Mike Bayer [Fri, 5 Aug 2022 21:25:05 +0000 (17:25 -0400)] 
deep compare CTEs before considering them conflicting

Fixed issue where referencing a CTE multiple times in conjunction with a
polymorphic SELECT could result in multiple "clones" of the same CTE being
constructed, which would then trigger these two CTEs as duplicates. To
resolve, the two CTEs are deep-compared when this occurs to ensure that
they are equivalent, then are treated as equivalent.

Fixes: #8357
Change-Id: I1f634a9cf7a6c4256912aac1a00506aecea3b0e2

2 years agoMerge "translate joined inheritance cols in UPDATE/DELETE" into main
mike bayer [Fri, 5 Aug 2022 19:29:26 +0000 (19:29 +0000)] 
Merge "translate joined inheritance cols in UPDATE/DELETE" into main

2 years agocredit @zeeeeeb for PG Multirange patch
Mike Bayer [Fri, 5 Aug 2022 17:17:44 +0000 (13:17 -0400)] 
credit @zeeeeeb for PG Multirange patch

Also move some of the PG docs to the .rst
page so we can link to sections.

References: #7156

Change-Id: If57abc768d4768058ffa768f9bf72f83c1ee6c29

2 years agoMerge "implement PG ranges/multiranges agnostically" into main
mike bayer [Fri, 5 Aug 2022 17:16:18 +0000 (17:16 +0000)] 
Merge "implement PG ranges/multiranges agnostically" into main

2 years agoMerge "fixes: #7156 - Adds support for PostgreSQL MultiRange type" into main
mike bayer [Fri, 5 Aug 2022 17:15:56 +0000 (17:15 +0000)] 
Merge "fixes: #7156 - Adds support for PostgreSQL MultiRange type" into main