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

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