]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
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 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

2 years agotranslate joined inheritance cols in UPDATE/DELETE
Mike Bayer [Wed, 3 Aug 2022 20:55:23 +0000 (16:55 -0400)] 
translate joined inheritance cols in UPDATE/DELETE

Fixed issue in ORM enabled UPDATE when the statement is created against a
joined-inheritance subclass, updating only local table columns, where the
"fetch" synchronization strategy would not render the correct RETURNING
clause for databases that use RETURNING for fetch synchronization.
Also adjusts the strategy used for RETURNING in UPDATE FROM and
DELETE FROM statements.

Also fixes MariaDB which does not support RETURNING with
DELETE..USING.  this was not caught in tests because
"fetch" strategy wasn't tested.  so also adjust the ORMDMLState
classes to look for "extra froms" first before adding
RETURNING, add new parameters to interfaces for
"update_returning_multitable" and "delete_returning_multitable".
A new execution option is_delete_using=True, described in the
changelog message, is added to allow the ORM to know up front
if a certain statement should have a SELECT up front
for "fetch" strategy.

Fixes: #8344
Change-Id: I3dcdb68e6e97ab0807a573c2fdb3d53c16d063ba

2 years agoMerge "include column.default, column.onupdate in eager_defaults" into main
mike bayer [Fri, 5 Aug 2022 14:54:12 +0000 (14:54 +0000)] 
Merge "include column.default, column.onupdate in eager_defaults" into main

2 years agoMerge "Support kw_only and match_args in dataclass mapping" into main
mike bayer [Fri, 5 Aug 2022 14:53:22 +0000 (14:53 +0000)] 
Merge "Support kw_only and match_args in dataclass mapping" into main

2 years agoimplement PG ranges/multiranges agnostically
Mike Bayer [Thu, 4 Aug 2022 14:27:59 +0000 (10:27 -0400)] 
implement PG ranges/multiranges agnostically

Ranges now work using a new Range object,
multiranges as lists of Range objects (this is what
asyncpg does.  not sure why psycopg has a "Multirange"
type).

psycopg, psycopg2, and asyncpg are currently supported.
It's not clear how to make ranges work with pg8000, likely
needs string conversion; this is straightforward with the
new archicture and can be added later.

Fixes: #8178
Change-Id: Iab8d8382873d5c14199adbe3f09fd0dc17e2b9f1

2 years agoinclude column.default, column.onupdate in eager_defaults
Mike Bayer [Tue, 2 Aug 2022 20:18:18 +0000 (16:18 -0400)] 
include column.default, column.onupdate in eager_defaults

Fixed bug in the behavior of the :paramref:`_orm.Mapper.eager_defaults`
parameter such that client-side SQL default or onupdate expressions in the
table definition alone will trigger a fetch operation using RETURNING or
SELECT when the ORM emits an INSERT or UPDATE for the row. Previously, only
server side defaults established as part of table DDL and/or server-side
onupdate expressions would trigger this fetch, even though client-side SQL
expressions would be included when the fetch was rendered.

Fixes: #7438
Change-Id: Iba719298ba4a26d185edec97ba77d2d54585e5a4

2 years agoMerge "deprecate Query.instances()" into main
mike bayer [Thu, 4 Aug 2022 20:30:19 +0000 (20:30 +0000)] 
Merge "deprecate Query.instances()" into main

2 years agoSupport kw_only and match_args in dataclass mapping
Federico Caselli [Wed, 3 Aug 2022 21:50:19 +0000 (23:50 +0200)] 
Support kw_only and match_args in dataclass mapping

Fixes: #8346
Change-Id: I964629e3bd25221bf6df6ab31c59b3ce1983cd9a

2 years agofixes: #7156 - Adds support for PostgreSQL MultiRange type
zeeeeb [Tue, 28 Jun 2022 23:05:08 +0000 (19:05 -0400)] 
fixes: #7156 - Adds support for PostgreSQL MultiRange type

This adds functionality for PostgreSQL MultiRange type, as discussed in Issue #7156.

As far as I can tell, only psycopg provides a [Multirange adaptation](https://www.psycopg.org/psycopg3/docs/basic/pgtypes.html#multirange-adaptation). Psycopg2 only supports a [Range adaptation/data type](https://www.psycopg.org/psycopg3/docs/basic/pgtypes.html#multirange-adaptation).

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.

Closes: #7816
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7816
Pull-request-sha: 7e9e0c858dcdb58d4fcca24964ef8d58d1842d41

Change-Id: I345e0f58f534ac37709a7a4627b6de8ddd8fa89e

2 years agoMerge "Fix 'No transaction found' error on Synapse." into main
mike bayer [Thu, 4 Aug 2022 13:37:38 +0000 (13:37 +0000)] 
Merge "Fix 'No transaction found' error on Synapse." into main

2 years agodeprecate Query.instances()
Mike Bayer [Wed, 3 Aug 2022 22:59:05 +0000 (18:59 -0400)] 
deprecate Query.instances()

this method no longer does the thing that it was originally
intended to do, which is to get ORM results from arbitrary
result sets.   Modern patterns should supersede the
use of this construct.

Change-Id: Ia1656c84d7c323f55e3a9594b950a40763d63d90
References: #8347

2 years agoMerge "ensure RETURNING renders in stringify w/ no server version" into main
mike bayer [Thu, 4 Aug 2022 13:32:17 +0000 (13:32 +0000)] 
Merge "ensure RETURNING renders in stringify w/ no server version" into main

2 years agoupdate quoted_name doc
Mike Bayer [Thu, 4 Aug 2022 13:26:47 +0000 (09:26 -0400)] 
update quoted_name doc

Fixes: #8339
Change-Id: If78bc9babfdc6a4dde4e65d72858ac7a402cbb4d

2 years agomore mysql 8.0.30 fixes
Mike Bayer [Thu, 4 Aug 2022 00:47:50 +0000 (20:47 -0400)] 
more mysql 8.0.30 fixes

Change-Id: I9df3506f364f4721404cf2022486bc31fd5c2ce6

2 years agoensure RETURNING renders in stringify w/ no server version
Mike Bayer [Wed, 3 Aug 2022 18:08:32 +0000 (14:08 -0400)] 
ensure RETURNING renders in stringify w/ no server version

just in my own testing, if I say insert().return_defaults()
and stringify, I should see it, so make sure all the dialects
default to "insert_returning" etc. , with downgrade on
server version check.

Change-Id: Id64e78fcb03c48b5dcb0feb21cb9cc495edd15e9

2 years agoadjust mysql utf test
Mike Bayer [Wed, 3 Aug 2022 22:09:39 +0000 (18:09 -0400)] 
adjust mysql utf test

we've updated mysql on jenkins and this test seems to need
a small adjustment

Change-Id: I21508f667700cf8f3200f15af501a66a85f48779

2 years agoglossary/association relationship: role->role_name (#8331)
Fabian Preiß [Wed, 3 Aug 2022 20:25:19 +0000 (22:25 +0200)] 
glossary/association relationship: role->role_name (#8331)

2 years agosend in the dragons on async_scoped_session
Mike Bayer [Wed, 3 Aug 2022 16:08:54 +0000 (12:08 -0400)] 
send in the dragons on async_scoped_session

make it clear that async_scoped_session.remove() must
be called, else memory will build up.    Generally
discourage the whole pattern as well, as this is a
"framework" pattern and we don't really want to be supporting
frameworks.    Also indicate that scopefunc must be idempotent
and lightweight.

Fixes: #8340
Change-Id: Ibc3d21124ae73c3b25ee51966504bbb1975c36b2

2 years agoreword yield_per a bit more
Mike Bayer [Tue, 2 Aug 2022 18:51:49 +0000 (14:51 -0400)] 
reword yield_per a bit more

I'm still not satisified with this section as it is still
too wordy and dense, but at least let's put a better description
of what yield_per actually is and why one might use it at the top.

Change-Id: I10f4d862d9c499044f5718fca0d27ac106289717

2 years agoFix 'No transaction found' error on Synapse.
Gord Thompson [Fri, 22 Jul 2022 12:31:24 +0000 (08:31 -0400)] 
Fix 'No transaction found' error on Synapse.

Fixed issue where the SQL Server dialect's query for the current isolation
level would fail on Azure Synapse Analytics, due to the way in which this
database handles transaction rollbacks after an error has occurred. The
initial query has been modified to no longer rely upon catching an error
when attempting to detect the appropriate system view. Additionally, to
better support this database's very specific "rollback" behavior,
implemented new parameter ``ignore_no_transaction_on_rollback`` indicating
that a rollback should ignore Azure Synapse error 'No corresponding
transaction found. (111214)', which is raised if no transaction is present
in conflict with the Python DBAPI.

Fixes: #8231
Closes: #8233
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8233
Pull-request-sha: c48bd44a9f53d00e5e94f1b8bf996711b6419562

Change-Id: I6407a03148f45cc9eba8fe1d31d4f59ebf9c7ef7

2 years agoMerge "SQLite reflection ignores schema internal names" into main
mike bayer [Tue, 2 Aug 2022 15:48:49 +0000 (15:48 +0000)] 
Merge "SQLite reflection ignores schema internal names" into main

2 years agoMerge "implement tuple-slices from .c collections" into main
mike bayer [Tue, 2 Aug 2022 15:46:28 +0000 (15:46 +0000)] 
Merge "implement tuple-slices from .c collections" into main

2 years agofix up SAVEPOINT docs
Mike Bayer [Tue, 2 Aug 2022 15:34:35 +0000 (11:34 -0400)] 
fix up SAVEPOINT docs

these contained a factual error that the entire session is
expired, which is no longer the case (I can't find exactly
when this was changed).  Additionally, added a PostgreSQL
specific example w/ IntegrityError as this is the most
common case for this.   Tried to tighten up other language
and make it as clear as possible.

Change-Id: I39160e7443964db59d1d5a2e0616084767813eea

2 years agoMerge "repair psycopg2 (and psycopg) multiple hosts format" into main
mike bayer [Tue, 2 Aug 2022 13:49:42 +0000 (13:49 +0000)] 
Merge "repair psycopg2 (and psycopg) multiple hosts format" into main

2 years agodocument @ sign in issue template, docs
Mike Bayer [Tue, 2 Aug 2022 13:33:51 +0000 (09:33 -0400)] 
document @ sign in issue template, docs

Fixes: #8328
Change-Id: I69a48c4499fe7e57aad242403186e69c4452b84b

2 years agoSQLite reflection ignores schema internal names
Federico Caselli [Sat, 30 Jul 2022 10:40:37 +0000 (12:40 +0200)] 
SQLite reflection ignores schema internal names

Added new parameter to SQLite for reflection methods called
``sqlite_include_internal=True``; when omitted, local tables that start
with the prefix ``sqlite_``, which per SQLite documentation are noted as
"internal schema" tables such as the ``sqlite_sequence`` table generated to
support "AUTOINCREMENT" columns, will not be included in reflection methods
that return lists of local objects. This prevents issues for example when
using Alembic autogenerate, which previously would consider these
SQLite-generated tables as being remove from the model.

Fixes: #8234
Change-Id: I36ee7a053e04b6c46c912aaa0d7e035a5b88a4f9

2 years agoimplement tuple-slices from .c collections
Mike Bayer [Wed, 27 Jul 2022 15:36:57 +0000 (11:36 -0400)] 
implement tuple-slices from .c collections

Added new syntax to the ``.c`` collection on all :class:`.FromClause`
objects allowing tuples of keys to be passed to ``__getitem__()``, along
with support for ``select()`` handling of ``.c`` collections directly,
allowing the syntax ``select(table.c['a', 'b', 'c'])`` to be possible. The
sub-collection returned is itself a :class:`.ColumnCollection` which is
also directly consumable by :func:`_sql.select` and similar now.

Fixes: #8285
Change-Id: I2236662c477ffc50af079310589e213323c960d1

2 years agorepair psycopg2 (and psycopg) multiple hosts format
Mike Bayer [Mon, 1 Aug 2022 14:29:13 +0000 (10:29 -0400)] 
repair psycopg2 (and psycopg) multiple hosts format

Fixed issue in psycopg2 dialect where the "multiple hosts" feature
implemented for :ticket:`4392`, where multiple ``host:port`` pairs could be
passed in the query string as
``?host=host1:port1&host=host2:port2&host=host3:port3`` was not implemented
correctly, as it did not propagate the "port" parameter appropriately.
Connections that didn't use a different "port" likely worked without issue,
and connections that had "port" for some of the entries may have
incorrectly passed on that hostname. The format is now corrected to pass
hosts/ports appropriately.

As part of this change, maintained support for another multihost style that
worked unintentionally, which is comma-separated
``?host=h1,h2,h3&port=p1,p2,p3``. This format is more consistent with
libpq's query-string format, whereas the previous format is inspired by a
different aspect of libpq's URI format but is not quite the same thing.

If the two styles are mixed together, an error is raised as this is
ambiguous.

Fixes: #4392
Change-Id: Ic9cc0b0e6e90725e158d9efe73e042853dd1263f

2 years agoexclude __new__
Mike Bayer [Sun, 31 Jul 2022 14:33:30 +0000 (10:33 -0400)] 
exclude __new__

due to Generic this method seems to be coming out everywhere
and it's just noise

Change-Id: I8fabb462d5faebb156b147fbd8f89dbb1b1ba380

2 years agoRemove `__cmp__` methods (#8313)
Nikita Sobolev [Sun, 31 Jul 2022 10:08:36 +0000 (13:08 +0300)] 
Remove `__cmp__` methods (#8313)

2 years agoUpdate to flake8 5.
Federico Caselli [Sun, 31 Jul 2022 09:56:07 +0000 (11:56 +0200)] 
Update to flake8 5.

Change-Id: I5a241a70efba68bcea9819ddce6aebc25703e68d

2 years agouse inherited members for Query
Mike Bayer [Sat, 30 Jul 2022 19:14:23 +0000 (15:14 -0400)] 
use inherited members for Query

not sure why these four methods were here, they don't
get sorted when doing it this way.

Change-Id: I554f132df3f299858ca5b451a79fbd9dd1f520ee

2 years agoRemove all `__nonzero__` methods (#8308)
Nikita Sobolev [Sat, 30 Jul 2022 18:48:26 +0000 (21:48 +0300)] 
Remove all `__nonzero__` methods (#8308)

2 years agoglossary: update the acronym definition (#8306)
bbben [Sat, 30 Jul 2022 18:43:59 +0000 (02:43 +0800)] 
glossary: update the acronym definition (#8306)

* glossary: fix typo

* add 'Read' to the CRUD definition

2 years agoBump actions/checkout from 2 to 3 (#8310)
dependabot[bot] [Sat, 30 Jul 2022 14:10:19 +0000 (16:10 +0200)] 
Bump actions/checkout from 2 to 3 (#8310)

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoBump actions/setup-python from 2 to 4 (#8309)
dependabot[bot] [Sat, 30 Jul 2022 11:44:54 +0000 (13:44 +0200)] 
Bump actions/setup-python from 2 to 4 (#8309)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agochore: Included githubactions in the dependabot config
Naveen [Sat, 30 Jul 2022 11:17:01 +0000 (07:17 -0400)] 
chore: Included githubactions in the dependabot config

This should help with keeping the GitHub actions updated on new releases. This will also help with keeping it secure.

Dependabot helps in keeping the supply chain secure https://docs.github.com/en/code-security/dependabot

GitHub actions up to date https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot

https://github.com/ossf/scorecard/blob/main/docs/checks.md#dependency-update-tool
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
Closes: #8180
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8180
Pull-request-sha: ef796e21f30da98c96e804bcdc056a17465525ca

Change-Id: I8252914951985de81dce944c3ab076dedf439cde

2 years agoglossary: primary_key needs value (#8298)
Fabian Preiß [Sat, 30 Jul 2022 10:47:15 +0000 (12:47 +0200)] 
glossary: primary_key needs value (#8298)

2 years agolink to index correctly
Mike Bayer [Sat, 30 Jul 2022 04:30:28 +0000 (00:30 -0400)] 
link to index correctly

Fixes: #8303
Change-Id: If3568309e4dd3e9ef715b32f9ad90eeba7f662e8

3 years agoMerge "feat: add `drop constraint if exists` to compiler" into main
mike bayer [Thu, 28 Jul 2022 18:19:44 +0000 (18:19 +0000)] 
Merge "feat: add `drop constraint if exists` to compiler" into main

3 years agoReflect expression-based indexes on PostgreSQL
Federico Caselli [Sat, 2 Jul 2022 21:49:07 +0000 (23:49 +0200)] 
Reflect expression-based indexes on PostgreSQL

The PostgreSQL dialect now supports reflection of expression based indexes.
The reflection is supported both when using
:meth:`_engine.Inspector.get_indexes` and when reflecting a
:class:`_schema.Table` using :paramref:`_schema.Table.autoload_with`.
Thanks to immerrr and Aidan Kane for the help on this ticket.

Fixes: #7442
Change-Id: I3e36d557235286c0f7f6d8276272ff9225058d48

3 years agoUpdate metadata.rst (#8290)
Paul Lettich [Tue, 26 Jul 2022 21:28:28 +0000 (23:28 +0200)] 
Update metadata.rst (#8290)

add missing colon in docs

3 years agofix lambda styles for relationship
Mike Bayer [Mon, 25 Jul 2022 13:26:40 +0000 (09:26 -0400)] 
fix lambda styles for relationship

Change-Id: I810fafc4cbcf0ac9b1f0de764130c81c56367a16

3 years agoset up Literal for synchronize_session
Mike Bayer [Sat, 23 Jul 2022 14:07:58 +0000 (10:07 -0400)] 
set up Literal for synchronize_session

Fixes: #8280
Change-Id: I59bc6cc0483375f79e17952188e0c2cde926502c

3 years agoremove mypy_path workaround and ensure messages received
Mike Bayer [Sat, 23 Jul 2022 14:18:06 +0000 (10:18 -0400)] 
remove mypy_path workaround and ensure messages received

Fixes: #8281
Change-Id: Ice47880ba7924daff68aef6b1791f3c66849f550

3 years agoclarify update perf test has only one test so far
Mike Bayer [Thu, 21 Jul 2022 13:41:50 +0000 (09:41 -0400)] 
clarify update perf test has only one test so far

this was pretty misleading as it shows up first in the
file listing

Change-Id: I6a92820e487a04632b651f9f6c631b32e338c043

3 years agoMerge "Use FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET" into main
mike bayer [Wed, 20 Jul 2022 17:29:59 +0000 (17:29 +0000)] 
Merge "Use FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET" into main

3 years agoMerge "add an extra load for non-new but unloaded" into main
mike bayer [Wed, 20 Jul 2022 15:41:56 +0000 (15:41 +0000)] 
Merge "add an extra load for non-new but unloaded" into main

3 years agoMerge "minor docs changes" into main
mike bayer [Wed, 20 Jul 2022 15:08:30 +0000 (15:08 +0000)] 
Merge "minor docs changes" into main

3 years agoUse FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET
Mike Bayer [Thu, 7 Jul 2022 16:07:39 +0000 (12:07 -0400)] 
Use FETCH FIRST N ROWS / OFFSET for Oracle LIMIT/OFFSET

Oracle will now use FETCH FIRST N ROWS / OFFSET syntax for limit/offset
support by default for Oracle 12c and above. This syntax was already
available when :meth:`_sql.Select.fetch` were used directly, it's now
implied for :meth:`_sql.Select.limit` and :meth:`_sql.Select.offset` as
well.

I'm currently setting this up so that the new syntax renders
in Oracle using POSTCOMPILE binds.    I really have no indication
if Oracle's SQL optimizer would be better with params
here, so that it can cache the SQL plan, or if it expects
hardcoded numbers for these. Since we had reports that the previous
ROWNUM thing really needed hardcoded ints, let's guess
for now that hardcoded ints would be preferable.  it can be turned
off with a single boolean if users report that they'd prefer
real bound values.

Fixes: #8221
Change-Id: I812ec24ffc947199866947b666d6ec6e6a690f22

3 years agoadd an extra load for non-new but unloaded
Mike Bayer [Thu, 23 Jun 2022 20:43:49 +0000 (16:43 -0400)] 
add an extra load for non-new but unloaded

Made an improvement to the "deferred" / "load_only" set of strategy options
where if a certain object is loaded from two different logical paths within
one query, attributes that have been configured by at least one of the
options to be populated will be populated in all cases, even if other load
paths for that same object did not set this option. previously, it was
based on randomness as to which "path" addressed the object first.

Fixes: #8166
Change-Id: I923a1484721d3a04d490ef882bc9fa609c9cd077

3 years agominor docs changes
Federico Caselli [Mon, 18 Jul 2022 21:31:15 +0000 (23:31 +0200)] 
minor docs changes

Change-Id: Iabcff11917eb267d0def191bee7ec03413d089e0

3 years agoMerge "fixes for mypy 0.971" into main
mike bayer [Tue, 19 Jul 2022 19:38:59 +0000 (19:38 +0000)] 
Merge "fixes for mypy 0.971" into main

3 years agoMerge "Ensure that a daclarative base is not used directly" into main
mike bayer [Tue, 19 Jul 2022 18:48:45 +0000 (18:48 +0000)] 
Merge "Ensure that a daclarative base is not used directly" into main

3 years agofixes for mypy 0.971
Mike Bayer [Tue, 19 Jul 2022 17:03:51 +0000 (13:03 -0400)] 
fixes for mypy 0.971

things that were passing with 0.961 need adjustment.
it seems mypy has become very pedantic about the difference
between importing from a module vs. accessing members of that
module as instance variables, so adjust the preloaded
typing block to be explicitly instance variables, since that's
how the accessor works in any case.

Change-Id: I746a3c9102530b7cf9b123aec7be6376657c1169

3 years agoMerge "check for TypeDecorator when handling getitem" into main
mike bayer [Tue, 19 Jul 2022 17:23:32 +0000 (17:23 +0000)] 
Merge "check for TypeDecorator when handling getitem" into main

3 years agocheck for TypeDecorator when handling getitem
Mike Bayer [Tue, 19 Jul 2022 14:50:05 +0000 (10:50 -0400)] 
check for TypeDecorator when handling getitem

Fixed issue where :class:`.TypeDecorator` would not correctly proxy the
``__getitem__()`` operator when decorating the :class:`.ARRAY` datatype,
without explicit workarounds.

Fixes: #7249
Change-Id: I3273572b4757e41fb5952639cb867314227d368a

3 years agorender all three elements selected in bundle example
Mike Bayer [Tue, 19 Jul 2022 15:13:59 +0000 (11:13 -0400)] 
render all three elements selected in bundle example

Fixes: #8013
Change-Id: I9b5f800d94abd80d07ca5f58c24f111618415674

3 years agoMerge "add shield() in aexit" into main
mike bayer [Mon, 18 Jul 2022 22:45:01 +0000 (22:45 +0000)] 
Merge "add shield() in aexit" into main

3 years agoEnsure that a daclarative base is not used directly
Federico Caselli [Fri, 15 Jul 2022 19:55:52 +0000 (21:55 +0200)] 
Ensure that a daclarative base is not used directly

Fixes: #8248
Change-Id: I4f4c690dd8659eaf74e9c757d681e9edc7d33eee

3 years agoMerge "implement executemany RETURNING for Oracle" into main
mike bayer [Mon, 18 Jul 2022 18:30:41 +0000 (18:30 +0000)] 
Merge "implement executemany RETURNING for Oracle" into main

3 years agoimplement executemany RETURNING for Oracle
Mike Bayer [Mon, 18 Jul 2022 16:52:28 +0000 (12:52 -0400)] 
implement executemany RETURNING for Oracle

this works straight out of the box as we can expand
upon what we did for #6245 to also receive for multiple
statements.    Oracle "fast ORM insert" then is basically done.

Fixes: #6245
Change-Id: I32902d199d473bc38cd03d14fec7482e1b37cd5b

3 years agoMerge "add contextmanager typing, open run_sync typing" into main
mike bayer [Mon, 18 Jul 2022 15:42:44 +0000 (15:42 +0000)] 
Merge "add contextmanager typing, open run_sync typing" into main

3 years agoadd shield() in aexit
Federico Caselli [Fri, 17 Jun 2022 21:12:39 +0000 (23:12 +0200)] 
add shield() in aexit

Added ``asyncio.shield()`` to the connection and session release process
specifically within the ``__aexit__()`` context manager exit, when using
:class:`.AsyncConnection` or :class:`.AsyncSession` as a context manager
that releases the object when the context manager is complete. This appears
to help with task cancellation when using alternate concurrency libraries
such as ``anyio``, ``uvloop`` that otherwise don't provide an async context
for the connection pool to release the connection properly during task
cancellation.

Fixes: #8145
Change-Id: I0b1ea9c3a22a18619341cbb8591225fcd339042c

3 years agoadd contextmanager typing, open run_sync typing
Mike Bayer [Mon, 18 Jul 2022 12:48:55 +0000 (08:48 -0400)] 
add contextmanager typing, open run_sync typing

was missing AsyncConnection type for the async
context manager.

fixing that revealed that _SyncConnectionCallable
and _SyncSessionCallable protocols are infeasible because
the given callable can have a lot of different signatures
that are compatible.

Change-Id: I559aa3dd88a902d0e7681c52223bb4bc0890adc1

3 years agouse concat() directly for contains, startswith, endswith
Mike Bayer [Sun, 17 Jul 2022 15:32:27 +0000 (11:32 -0400)] 
use concat() directly for contains, startswith, endswith

Adjusted the SQL compilation for string containment functions
``.contains()``, ``.startswith()``, ``.endswith()`` to force the use of the
string concatenation operator, rather than relying upon the overload of the
addition operator, so that non-standard use of these operators with for
example bytestrings still produces string concatenation operators.

To accommodate this, needed to add a new _rconcat operator function,
which is private, as well as a fallback in concat_op() that works
similarly to Python builtin ops.

Fixes: #8253
Change-Id: I2b7f56492f765742d88cb2a7834ded6a2892bd7e

3 years agoMerge "implement column._merge()" into main
mike bayer [Sun, 17 Jul 2022 01:14:39 +0000 (01:14 +0000)] 
Merge "implement column._merge()" into main

3 years agoimplement column._merge()
Mike Bayer [Sat, 16 Jul 2022 20:19:15 +0000 (16:19 -0400)] 
implement column._merge()

this takes the user-defined args of one Column and merges
them into the not-user-defined args of another Column.

Implemented within the pep-593 column transfer operation
to begin to make this new feature more robust.

work may still be needed for constraints etc. but
in theory everything from the left side annotated column
should take effect for the right side if not otherwise
specified on the right.

Change-Id: I57eb37ed6ceb4b60979a35cfc4b63731d990911d

3 years agoupdate ORM declarative docs for new features
Mike Bayer [Fri, 15 Jul 2022 16:53:37 +0000 (12:53 -0400)] 
update ORM declarative docs for new features

I screwed up a rebase or something so this was
temporarily in Ic51a12de3358f3a451bd7cf3542b375569499fc1

Change-Id: I847ee1336381221c0112b67854df022edf596b25

3 years agoMerge "make anno-only Mapped[] column available for mixins" into main
mike bayer [Fri, 15 Jul 2022 17:57:19 +0000 (17:57 +0000)] 
Merge "make anno-only Mapped[] column available for mixins" into main

3 years agoremove needlessly complex assoc proxy mixin example
Mike Bayer [Fri, 15 Jul 2022 16:53:37 +0000 (12:53 -0400)] 
remove needlessly complex assoc proxy mixin example

this is some very exotic example that doesn't really
explain anything new about mixins and only serves
to make the docs less accessible.

Change-Id: Ic51a12de3358f3a451bd7cf3542b375569499fc1

3 years agomake anno-only Mapped[] column available for mixins
Mike Bayer [Fri, 15 Jul 2022 16:25:22 +0000 (12:25 -0400)] 
make anno-only Mapped[] column available for mixins

Documentation is relying on the recently improved
behavior of produce_column_copies() to make sure everything is
available on cls for a declared_attr.  therefore for anno-only
attribute, we also need to generate the mapped_column() up front
before scan is called.

noticed in pylance, allow @declared_attr to recognize
@classmethod also which allows letting typing tools know
something is explicitly a classmethod

Change-Id: I07ff1a642a75679f685914a33c674807929f4918

3 years agostep five
Mike Bayer [Fri, 15 Jul 2022 12:55:08 +0000 (08:55 -0400)] 
step five

Change-Id: Ib6242d676c800b4b679aaf7f33f641ebcaed5b33

3 years agoMinor cleanup
Federico Caselli [Wed, 13 Jul 2022 21:18:57 +0000 (23:18 +0200)] 
Minor cleanup

- remove unnecessary postgresql visit that's equal to the default compiler
- clarify type_annotation_map documentation

Change-Id: I0c1fa212d06f6af799a5894802574250622c855e

3 years agosupport dataclasses with MutableComposite
Mike Bayer [Wed, 13 Jul 2022 18:30:36 +0000 (14:30 -0400)] 
support dataclasses with MutableComposite

basically a one line change

Change-Id: If6a70d49777e77f86e2b6936dd4aece20b00708e

3 years agoMerge "implement comparison ops for composites" into main
mike bayer [Wed, 13 Jul 2022 17:43:46 +0000 (17:43 +0000)] 
Merge "implement comparison ops for composites" into main

3 years agoimplement comparison ops for composites
Mike Bayer [Wed, 13 Jul 2022 16:48:37 +0000 (12:48 -0400)] 
implement comparison ops for composites

classes mapped by :class:`_orm.composite` now support
ordering comparison operations, e.g. ``<``, ``>=``, etc.

Change-Id: I44938b9ca2935b2f63c70e930768487ddc6b7669

3 years agodocument create_engine.isolation_level for PG
Mike Bayer [Wed, 13 Jul 2022 15:02:37 +0000 (11:02 -0400)] 
document create_engine.isolation_level for PG

Change-Id: I06eaede9e021eb0790929168e9bedb0c8b58140a
References: #8252

3 years agoMerge "Update docs for association_proxy" into main
mike bayer [Wed, 13 Jul 2022 00:41:26 +0000 (00:41 +0000)] 
Merge "Update docs for association_proxy" into main

3 years agoUpdate docs for association_proxy
Gord Thompson [Fri, 8 Jul 2022 17:50:54 +0000 (11:50 -0600)] 
Update docs for association_proxy

Make naming more consistent and explicit

Change-Id: If90de9ab8b10348d6d1547b9fd6e3b2c312d9ee8

3 years agoMerge "add some typing tests for declared_attr, mixins, decl base" into main
mike bayer [Tue, 12 Jul 2022 14:24:28 +0000 (14:24 +0000)] 
Merge "add some typing tests for declared_attr, mixins, decl base" into main

3 years agosupport "SELECT *" for ORM queries
Mike Bayer [Mon, 11 Jul 2022 01:24:17 +0000 (21:24 -0400)] 
support "SELECT *" for ORM queries

A :func:`_sql.select` construct that is passed a sole '*' argument for
``SELECT *``, either via string, :func:`_sql.text`, or
:func:`_sql.literal_column`, will be interpreted as a Core-level SQL
statement rather than as an ORM level statement. This is so that the ``*``,
when expanded to match any number of columns, will result in all columns
returned in the result. the ORM- level interpretation of
:func:`_sql.select` needs to know the names and types of all ORM columns up
front which can't be achieved when ``'*'`` is used.

If ``'*`` is used amongst other expressions simultaneously with an ORM
statement, an error is raised as this can't be interpreted correctly by the
ORM.

Fixes: #8235
Change-Id: Ic8e84491e14acdc8570704eadeaeaf6e16b1e870

3 years agoadd some typing tests for declared_attr, mixins, decl base
Mike Bayer [Fri, 8 Jul 2022 18:36:25 +0000 (14:36 -0400)] 
add some typing tests for declared_attr, mixins, decl base

to make typing easier, looking at using getattr on table.c
rather than getitem for now

Change-Id: I7946885071d0b0ddfc06be009f033495f9906de5

3 years agodocument using fetch() with Oracle
Mike Bayer [Thu, 7 Jul 2022 15:44:09 +0000 (11:44 -0400)] 
document using fetch() with Oracle

We implemented working FETCH support, but it's not
yet implied by limit/offset.  The docs make no mention
that this is available which is very misleading including
to maintainers.    Make it clear that fetch() support is
there right now, it's just not yet implicit with
limit/offset.

Change-Id: Ib2231dcdd80a8bf3ac4bbf590e1a8dfeac31e9da
References: #8221

3 years agoMerge "generalize sql server check for id col to accommodate ORM cases" into main
mike bayer [Wed, 6 Jul 2022 15:16:48 +0000 (15:16 +0000)] 
Merge "generalize sql server check for id col to accommodate ORM cases" into main

3 years agogeneralize sql server check for id col to accommodate ORM cases
Mike Bayer [Wed, 6 Jul 2022 01:05:18 +0000 (21:05 -0400)] 
generalize sql server check for id col to accommodate ORM cases

Fixed issues that prevented the new usage patterns for using DML with ORM
objects presented at :ref:`orm_dml_returning_objects` from working
correctly with the SQL Server pyodbc dialect.

Here we add a step to look in compile_state._dict_values more thoroughly
for the keys we need to determine "identity insert" or not, and also
add a new compiler variable dml_compile_state so that we can skip the
ORM's compile_state if present.

Fixes: #8210
Change-Id: Idbd76bb3eb075c647dc6c1cb78f7315c821e15f7

3 years agoMerge "test transfer of default, insert_default" into main
mike bayer [Wed, 6 Jul 2022 02:04:41 +0000 (02:04 +0000)] 
Merge "test transfer of default, insert_default" into main

3 years agoMerge "move backref to "legacy"" into main
mike bayer [Mon, 4 Jul 2022 18:13:57 +0000 (18:13 +0000)] 
Merge "move backref to "legacy"" into main