]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agoadd more pg ENUM tests
Mike Bayer [Tue, 21 Jun 2022 18:07:49 +0000 (14:07 -0400)] 
add more pg ENUM tests

given 017fd9ae0645eaf2a0fbdd067d10c has changed 'name'
to be required for ENUM, add some more adapt from Enum types
of tests.

Change-Id: I447983e640d6466f969aa51c8dff5a0cb8074ca8

3 years agoDomain type
David Baumgold [Fri, 11 Feb 2022 17:30:24 +0000 (12:30 -0500)] 
Domain type

Added a new Postgresql :class:`_postgresql.DOMAIN` datatype, which follows
the same CREATE TYPE / DROP TYPE behaviors as that of PostgreSQL
:class:`_postgresql.ENUM`. Much thanks to David Baumgold for the efforts on
this.

Fixes: #7316
Closes: #7317
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7317
Pull-request-sha: bc9a82f010e6ca2f70a6e8a7620b748e483c26c3

Change-Id: Id8d7e48843a896de17d20cc466b115b3cc065132

3 years agoremove warnings for index/unique skipped due to exclude_cols
Mike Bayer [Mon, 20 Jun 2022 15:06:34 +0000 (11:06 -0400)] 
remove warnings for index/unique skipped due to exclude_cols

The warnings that are emitted regarding reflection of indexes or unique
constraints, when the :paramref:`.Table.include_columns` parameter is used
to exclude columns that are then found to be part of those constraints,
have been removed. When the :paramref:`.Table.include_columns` parameter is
used it should be expected that the resulting :class:`.Table` construct
will not include constraints that rely upon omitted columns. This change
was made in response to :ticket:`8100` which repaired
:paramref:`.Table.include_columns` in conjunction with foreign key
constraints that rely upon omitted columns, where the use case became
clear that omitting such constraints should be expected.

Fixes: #8102
Change-Id: Id32f628def2d12499cd49d0b436ed345fe49dc6b

3 years agoMerge "create new approach for deeply nested post loader options" into main
mike bayer [Sat, 18 Jun 2022 21:52:25 +0000 (21:52 +0000)] 
Merge "create new approach for deeply nested post loader options" into main

3 years agoMerge "rearchitect reflection for batched performance" into main
Federico Caselli [Sat, 18 Jun 2022 21:08:27 +0000 (21:08 +0000)] 
Merge "rearchitect reflection for batched performance" into main

3 years agocreate new approach for deeply nested post loader options
Mike Bayer [Thu, 16 Jun 2022 17:35:16 +0000 (13:35 -0400)] 
create new approach for deeply nested post loader options

Added very experimental feature to the :func:`_orm.selectinload` and
:func:`_orm.immediateload` loader options called
:paramref:`_orm.selectinload.recursion_depth` /
:paramref:`_orm.immediateload.recursion_depth` , which allows a single
loader option to automatically recurse into self-referential relationships.
Is set to an integer indicating depth, and may also be set to -1 to
indicate to continue loading until no more levels deep are found.
Major internal changes to :func:`_orm.selectinload` and
:func:`_orm.immediateload` allow this feature to work while continuing
to make correct use of the compilation cache, as well as not using
arbitrary recursion, so any level of depth is supported (though would
emit that many queries).  This may be useful for
self-referential structures that must be loaded fully eagerly, such as when
using asyncio.

A warning is also emitted when loader options are connected together with
arbitrary lengths (that is, without using the new ``recursion_depth``
option) when excessive recursion depth is detected in related object
loading. This operation continues to use huge amounts of memory and
performs extremely poorly; the cache is disabled when this condition is
detected to protect the cache from being flooded with arbitrary statements.

Fixes: #8126
Change-Id: I9f162e0a09c1ed327dd19498aac193f649333a01

3 years agoMerge "Normalize postgresql docs links to point to current" into main
mike bayer [Sat, 18 Jun 2022 19:00:16 +0000 (19:00 +0000)] 
Merge "Normalize postgresql docs links to point to current" into main

3 years agoMerge "Allow NUMERIC()/DECIMAL() IDENTITY columns" into main
mike bayer [Sat, 18 Jun 2022 18:59:48 +0000 (18:59 +0000)] 
Merge "Allow NUMERIC()/DECIMAL() IDENTITY columns" into main

3 years agorearchitect reflection for batched performance
Federico Caselli [Thu, 14 Oct 2021 19:45:57 +0000 (21:45 +0200)] 
rearchitect reflection for batched performance

Rearchitected the schema reflection API to allow some dialects to make use
of high performing batch queries to reflect the schemas of many tables at
once using much fewer queries. The new performance features are targeted
first at the PostgreSQL and Oracle backends, and may be applied to any
dialect that makes use of SELECT queries against system catalog tables to
reflect tables (currently this omits the MySQL and SQLite dialects which
instead make use of parsing the "CREATE TABLE" statement, however these
dialects do not have a pre-existing performance issue with reflection. MS
SQL Server is still a TODO).

The new API is backwards compatible with the previous system, and should
require no changes to third party dialects to retain compatibility;
third party dialects can also opt into the new system by implementing
batched queries for schema reflection.

Along with this change is an updated reflection API that is fully
:pep:`484` typed, features many new methods and some changes.

Fixes: #4379
Change-Id: I897ec09843543aa7012bcdce758792ed3d415d08

3 years agoAllow NUMERIC()/DECIMAL() IDENTITY columns
Gord Thompson [Tue, 14 Jun 2022 16:09:04 +0000 (10:09 -0600)] 
Allow NUMERIC()/DECIMAL() IDENTITY columns

Fixed issue where :class:`.Table` objects that made use of IDENTITY columns
with a :class:`.Numeric` datatype would produce errors when attempting to
reconcile the "autoincrement" column, preventing construction of the
:class:`.Column` from using the :paramref:`.Column.autoincrement` parameter
as well as emitting errors when attempting to invoke an :class:`.Insert`
construct.

Fixes: #8111
Change-Id: Iaacc4eebfbafb42fa18f9a1a4f43cb2b6b91d28a

3 years agoNormalize postgresql docs links to point to current
Federico Caselli [Fri, 17 Jun 2022 19:53:32 +0000 (21:53 +0200)] 
Normalize postgresql docs links to point to current

Change-Id: Ib7d3ea7ff3356ff8a2f935892d904a69dbc25c3e

3 years agoRevert "add auto_recurse option to selectinload, immediateload"
Mike Bayer [Thu, 16 Jun 2022 18:46:11 +0000 (14:46 -0400)] 
Revert "add auto_recurse option to selectinload, immediateload"

this option works very badly with caching and the API
is likely not what we want either.  Work continues for
 #8126 including that the additional work in
I9f162e0a09c1ed327dd19498aac193f649333a01
tries to add new recursive features.

This reverts commit b3a1162553879d1369154e920f3f4129020bb88e.

3 years agoMerge "implement literal stringification for arrays" into main
mike bayer [Thu, 16 Jun 2022 02:30:04 +0000 (02:30 +0000)] 
Merge "implement literal stringification for arrays" into main

3 years agoimplement literal stringification for arrays
Mike Bayer [Wed, 15 Jun 2022 16:42:44 +0000 (12:42 -0400)] 
implement literal stringification for arrays

as we already implement stringification for the contents,
provide a bracketed syntax for default and ARRAY literal
for PG specifically.   ARRAY literal seems much simpler to
render than their quoted syntax which requires double quotes
for strings.

also open up testing for pg8000 which has likely been
fine with arrays for awhile now, bump the version pin
also.

Fixes: #8138
Change-Id: Id85b052b0a9564d6aa1489160e58b7359f130fdd

3 years agoremove sqlalchemy2-stubs dep from mypy setup.cfg extras
Mike Bayer [Wed, 15 Jun 2022 17:02:22 +0000 (13:02 -0400)] 
remove sqlalchemy2-stubs dep from mypy setup.cfg extras

this should have been removed awhile ago.

Change-Id: I181bd31936fbd811b34e6a9de44b65857146e359

3 years agoMerge "new features for pep 593 Annotated" into main
mike bayer [Wed, 15 Jun 2022 14:07:53 +0000 (14:07 +0000)] 
Merge "new features for pep 593 Annotated" into main

3 years agonew features for pep 593 Annotated
Mike Bayer [Tue, 14 Jun 2022 21:05:44 +0000 (17:05 -0400)] 
new features for pep 593 Annotated

* extract the inner type from Annotated when the outer type
  isn't present in the type map, to allow for arbitrary Annotated
* allow _IntrospectsAnnotations objects to be directly present
  in an Annotated and resolve the mapper property from that.
  Currently implemented for mapped_column(), with message for
  others.  Can work for composite() and likely some
  relationship() as well at some point

References: https://twitter.com/zzzeek/status/1536693554621341697 and
replies

Change-Id: I04657050a8785f194bf8f63291faf3475af88781

3 years agoMerge "pickle mutable parents according to key" into main
mike bayer [Wed, 15 Jun 2022 01:46:39 +0000 (01:46 +0000)] 
Merge "pickle mutable parents according to key" into main

3 years agopickle mutable parents according to key
Mike Bayer [Tue, 14 Jun 2022 19:41:31 +0000 (15:41 -0400)] 
pickle mutable parents according to key

Fixed bug in :class:`.Mutable` where pickling and unpickling of an ORM
mapped instance would not correctly restore state for mappings that
contained multiple :class:`.Mutable`-enabled attributes.

Fixes: #8133
Change-Id: I508763e0df0d7a624e1169f9a46d7f25404add1e

3 years agoMerge "Remove reflect=True in Base.prepare examples" into main
mike bayer [Tue, 14 Jun 2022 20:13:26 +0000 (20:13 +0000)] 
Merge "Remove reflect=True in Base.prepare examples" into main

3 years agoMerge "typing adjustments for composites" into main
mike bayer [Tue, 14 Jun 2022 20:12:10 +0000 (20:12 +0000)] 
Merge "typing adjustments for composites" into main

3 years agoMerge branch 'workflow_test_json'
Federico Caselli [Tue, 14 Jun 2022 19:56:29 +0000 (21:56 +0200)] 
Merge branch 'workflow_test_json'

Change-Id: I2112f9726fbbbb028ed5ce91f722573913b711de

3 years agotyping adjustments for composites
Mike Bayer [Tue, 14 Jun 2022 13:31:09 +0000 (09:31 -0400)] 
typing adjustments for composites

* if dataclass isn't used, columns have to be named
* _CompositeClassProto is not useful as dataclasses have no
  methods / bases we can use, so composite is against Any
* Adjust session.get() feature to work w/ dataclass composites

Change-Id: Icc606cc76871c738dc794ea4555fca8a1ab0e0fd

3 years agoadd contextual detail to cython change message
Mike Bayer [Tue, 14 Jun 2022 14:10:30 +0000 (10:10 -0400)] 
add contextual detail to cython change message

Change-Id: I57014a16f4718bdbe6eb91b8aeed7075cb4df5f1

3 years agoRemove reflect=True in Base.prepare examples
Gord Thompson [Tue, 14 Jun 2022 13:27:31 +0000 (07:27 -0600)] 
Remove reflect=True in Base.prepare examples

Change-Id: Icdb17fab0f92762a266efbe1a64bec1d5a6dc9ab

3 years agotry fixing the build
Federico Caselli [Mon, 13 Jun 2022 20:15:48 +0000 (22:15 +0200)] 
try fixing the build

Change-Id: Id2e965aa13a6d7134ca1081554cc5b25dbcc9fde

3 years agoremove docs from path ignore in the tests
Federico Caselli [Mon, 13 Jun 2022 19:48:34 +0000 (21:48 +0200)] 
remove docs from path ignore in the tests

Change-Id: I1d399d9532bc63d00a730e3981aef79ad99a97bb

3 years agoneed to use List here since we test on 3.7 at the moment
Mike Bayer [Mon, 13 Jun 2022 16:41:44 +0000 (12:41 -0400)] 
need to use List here since we test on 3.7 at the moment

Change-Id: I8a92fb81a71ae3936f299e2794f1d710fea0a589

3 years agoedits
Mike Bayer [Mon, 13 Jun 2022 15:58:46 +0000 (11:58 -0400)] 
edits

i dont have a good way to preview this.  not sure how i should
be editing here.

Change-Id: I399a5b0fa3fd2a03bbdc66f3a1dcb21043f7214a

3 years agoedits
Mike Bayer [Mon, 13 Jun 2022 15:56:04 +0000 (11:56 -0400)] 
edits

Change-Id: Id0bf143e948255c473558c68b3471fbe62bd98f6

3 years agotry to encourage more discussions, less bugs
Mike Bayer [Mon, 13 Jun 2022 15:54:06 +0000 (11:54 -0400)] 
try to encourage more discussions, less bugs

Change-Id: If7e07fffeea6d32af4f2e819111315783e902b8e

3 years agoMerge "add auto_recurse option to selectinload, immediateload" into main
mike bayer [Sun, 12 Jun 2022 17:46:33 +0000 (17:46 +0000)] 
Merge "add auto_recurse option to selectinload, immediateload" into main

3 years agoupdate quickstart for 2.0
Mike Bayer [Sun, 12 Jun 2022 16:07:54 +0000 (12:07 -0400)] 
update quickstart for 2.0

this is just so we can point people to something
while I get around to doing the rest of the docs

Change-Id: Ie818024a80ad30b76d7f7d6dc179939c246084c6

3 years agoadd auto_recurse option to selectinload, immediateload
Mike Bayer [Sat, 11 Jun 2022 15:33:46 +0000 (11:33 -0400)] 
add auto_recurse option to selectinload, immediateload

Added very experimental feature to the :func:`_orm.selectinload` and
:func:`_orm.immediateload` loader options called
:paramref:`_orm.selectinload.auto_recurse` /
:paramref:`_orm.immediateload.auto_recurse` , which when set to True will
cause a self-referential relationship load to continue loading with
arbitrary depth until no further objects are found. This may be useful for
self-referential structures that must be loaded fully eagerly, such as when
using asyncio.

Fixes: #8126
Change-Id: I5bbd00bd0ca43f4649b44680fea1e84680f0a5db

3 years agoMerge "honor enum length in all cases" into main
mike bayer [Fri, 10 Jun 2022 18:19:06 +0000 (18:19 +0000)] 
Merge "honor enum length in all cases" into main

3 years agoMerge "resolve large ints to BigInteger" into main
mike bayer [Fri, 10 Jun 2022 18:18:35 +0000 (18:18 +0000)] 
Merge "resolve large ints to BigInteger" into main

3 years agoresolve large ints to BigInteger
Mike Bayer [Fri, 10 Jun 2022 16:57:53 +0000 (12:57 -0400)] 
resolve large ints to BigInteger

The in-place type detection for Python integers, as occurs with an
expression such as ``literal(25)``, will now apply value-based adaption as
well to accommodate Python large integers, where the datatype determined
will be :class:`.BigInteger` rather than :class:`.Integer`. This
accommodates for dialects such as that of asyncpg which both sends implicit
typing information to the driver as well as is sensitive to numeric scale.

Fixes: #7909
Change-Id: I1cd3ec2676c9bb03ffedb600695252bd0037ba02

3 years agohonor enum length in all cases
Mike Bayer [Fri, 10 Jun 2022 16:42:54 +0000 (12:42 -0400)] 
honor enum length in all cases

The :paramref:`.Enum.length` parameter, which sets the length of the
``VARCHAR`` column for non-native enumeration types, is now used
unconditionally when emitting DDL for the ``VARCHAR`` datatype, including
when the :paramref:`.Enum.native_enum` parameter is set to ``True`` for
target backends that continue to use ``VARCHAR``. Previously the parameter
would be erroneously ignored in this case. The warning previously emitted
for this case is now removed.

Fixes: #7791
Change-Id: I91764546b56e9416479949be8a118cdc91ac5ed9

3 years agoremove "undefer_pks" as a strategy option
Mike Bayer [Fri, 10 Jun 2022 15:44:45 +0000 (11:44 -0400)] 
remove "undefer_pks" as a strategy option

The behavior of :func:`_orm.defer` regarding primary key and "polymorphic
discriminator" columns is revised such that these columns are no longer
deferrable, either explicitly or when using a wildcard such as
``defer('*')``. Previously, a wildcard deferral would not load
PK/polymorphic columns which led to errors in all cases, as the ORM relies
upon these columns to produce object identities. The behavior of explicit
deferral of primary key columns is unchanged as these deferrals already
were implicitly ignored.

Fixes: #7495
Change-Id: I76d9252426e86619bc142667670a3df75b4f5f6a

3 years agoMerge "update cx_Oracle / oracledb LOB handling" into main
mike bayer [Fri, 10 Jun 2022 15:11:44 +0000 (15:11 +0000)] 
Merge "update cx_Oracle / oracledb LOB handling" into main

3 years agoupdate cx_Oracle / oracledb LOB handling
Mike Bayer [Tue, 7 Jun 2022 20:09:35 +0000 (16:09 -0400)] 
update cx_Oracle / oracledb LOB handling

Adjustments made to the BLOB / CLOB / NCLOB datatypes in the cx_Oracle and
oracledb dialects, to improve performance based on recommendations from
Oracle developers.

References: https://github.com/oracle/python-cx_Oracle/issues/596
Fixes: #7494
Change-Id: I0d8cc3579140aa65cacf5b7d3373f7e1929a8f85

3 years agoMerge "restore parameter escaping for public methods" into main
mike bayer [Thu, 9 Jun 2022 16:03:53 +0000 (16:03 +0000)] 
Merge "restore parameter escaping for public methods" into main

3 years agoMerge "handle non-mapped mixins for with_loader_criteria reduce" into main
mike bayer [Thu, 9 Jun 2022 16:02:21 +0000 (16:02 +0000)] 
Merge "handle non-mapped mixins for with_loader_criteria reduce" into main

3 years agoMerge "dont transfer __weakref__ to regenerated class" into main
mike bayer [Thu, 9 Jun 2022 16:01:26 +0000 (16:01 +0000)] 
Merge "dont transfer __weakref__ to regenerated class" into main

3 years agoRevert "document thread safety workaround for lambda statements"
Mike Bayer [Thu, 9 Jun 2022 14:56:59 +0000 (10:56 -0400)] 
Revert "document thread safety workaround for lambda statements"

This reverts commit bf40bade26e32fc3757bbd756f4c9ebdc5d72090.

3 years agorestore parameter escaping for public methods
Mike Bayer [Thu, 9 Jun 2022 01:35:02 +0000 (21:35 -0400)] 
restore parameter escaping for public methods

Adjusted the fix made for :ticket:`8056` which adjusted the escaping of
bound parameter names with special characters such that the escaped names
were translated after the SQL compilation step, which broke a published
recipe on the FAQ illustrating how to merge parameter names into the string
output of a compiled SQL string. The change restores the escaped names that
come from ``compiled.params`` and adds a conditional parameter to
:meth:`.SQLCompiler.construct_params` named ``escape_names`` that defaults
to ``True``, restoring the old behavior by default.

Fixes: #8113
Change-Id: I9cbedb1080bc06d51f287fd2cbf26aaab1c74653

3 years agodont transfer __weakref__ to regenerated class
Mike Bayer [Thu, 9 Jun 2022 13:53:43 +0000 (09:53 -0400)] 
dont transfer __weakref__ to regenerated class

Repaired a deprecation warning class decorator that was preventing key
objects such as :class:`_engine.Connection` from having a proper
``__weakref__`` attribute, causing operations like Python standard library
``inspect.getmembers()`` to fail.

Fixes: #8115
Change-Id: Ifd0bc2325fb9dc9e1431998c308b7fc081968373

3 years agohandle non-mapped mixins for with_loader_criteria reduce
Mike Bayer [Thu, 9 Jun 2022 12:55:14 +0000 (08:55 -0400)] 
handle non-mapped mixins for with_loader_criteria reduce

special handling is needed for a with_loader_criteria()
against a non-mapped mixin class.  added that to test
coverage

Fixes: #8109
Change-Id: Ia599361c8faab008e92095eb4607d02820f590d5

3 years agoMerge "fix race conditions in lambda statements" into main
mike bayer [Thu, 9 Jun 2022 12:37:17 +0000 (12:37 +0000)] 
Merge "fix race conditions in lambda statements" into main

3 years agoMerge "suppport with_loader_criteria pickling w/ fixed callable" into main
mike bayer [Thu, 9 Jun 2022 00:54:16 +0000 (00:54 +0000)] 
Merge "suppport with_loader_criteria pickling w/ fixed callable" into main

3 years agoadd tests to confirm no issue w/ pg json keys
Mike Bayer [Wed, 8 Jun 2022 23:04:23 +0000 (19:04 -0400)] 
add tests to confirm no issue w/ pg json keys

Change-Id: Ie91e5efb217c309bc40c3933f538bcf29c1fd87b
References: #8112

3 years agodocument thread safety workaround for lambda statements
Mike Bayer [Wed, 8 Jun 2022 20:03:26 +0000 (16:03 -0400)] 
document thread safety workaround for lambda statements

Change-Id: Idb7840ff64487ef985087a28bb6e96088e6a392e
References: #8098

3 years agoMerge "graceful degrade for FKs not reflectable" into main
mike bayer [Wed, 8 Jun 2022 17:13:28 +0000 (17:13 +0000)] 
Merge "graceful degrade for FKs not reflectable" into main

3 years agosuppport with_loader_criteria pickling w/ fixed callable
Mike Bayer [Wed, 8 Jun 2022 17:05:20 +0000 (13:05 -0400)] 
suppport with_loader_criteria pickling w/ fixed callable

Fixed issue where a :func:`_orm.with_loader_criteria` option could not be
pickled, as is necessary when it is carried along for propagation to lazy
loaders in conjunction with a caching scheme. Currently, the only form that
is supported as picklable is to pass the "where criteria" as a fixed
module-level callable function that produces a SQL expression. An ad-hoc
"lambda" can't be pickled, and a SQL expression object is usually not fully
picklable directly.

Fixes: #8109
Change-Id: I49fe69088b0c7e58a0f22c67d2ea4e33752a5a73

3 years agoadd note re: pickling for loader criteria
Mike Bayer [Wed, 8 Jun 2022 15:54:46 +0000 (11:54 -0400)] 
add note re: pickling for loader criteria

Change-Id: I75992af71ba08799a03995178a6e4612c9a7428a
References: #8108

3 years agofix race conditions in lambda statements
Mike Bayer [Tue, 7 Jun 2022 19:00:20 +0000 (15:00 -0400)] 
fix race conditions in lambda statements

Fixed multiple observed race conditions related to :func:`.lambda_stmt`,
including an initial "dogpile" issue when a new Python code object is
initially analyzed among multiple simultaneous threads which created both a
performance issue as well as some internal corruption of state.
Additionally repaired observed race condition which could occur when
"cloning" an expression construct that is also in the process of being
compiled or otherwise accessed in a different thread due to memoized
attributes altering the ``__dict__`` while iterated, for Python versions
prior to 3.10; in particular the lambda SQL construct is sensitive to this
as it holds onto a single statement object persistently. The iteration has
been refined to use ``dict.copy()`` with or without an additional iteration
instead.

Fixes: #8098
Change-Id: I4e0b627bfa187f1780dc68ec81b94db1c78f846a

3 years agoMerge "Add support for the new oracle driver ``oracledb``." into main
mike bayer [Tue, 7 Jun 2022 18:46:36 +0000 (18:46 +0000)] 
Merge "Add support for the new oracle driver ``oracledb``." into main

3 years agoMerge "migrate labels to new tutorial" into main
mike bayer [Tue, 7 Jun 2022 17:02:20 +0000 (17:02 +0000)] 
Merge "migrate labels to new tutorial" into main

3 years agoAdd support for the new oracle driver ``oracledb``.
Federico Caselli [Fri, 3 Jun 2022 12:51:04 +0000 (14:51 +0200)] 
Add support for the new oracle driver ``oracledb``.

Fixes: #8054
Change-Id: Idd7c1bbb7ca39499f53bdf59a63a6a9d65f144a5

3 years agograceful degrade for FKs not reflectable
Mike Bayer [Tue, 7 Jun 2022 13:40:26 +0000 (09:40 -0400)] 
graceful degrade for FKs not reflectable

Fixed bugs involving the :paramref:`.Table.include_columns` and the
:paramref:`.Table.resolve_fks` parameters on :class:`.Table`; these
little-used parameters were apparently not working for columns that refer
to foreign key constraints.

In the first case, not-included columns that refer to foreign keys would
still attempt to create a :class:`.ForeignKey` object, producing errors
when attempting to resolve the columns for the foreign key constraint
within reflection; foreign key constraints that refer to skipped columns
are now omitted from the table reflection process in the same way as
occurs for :class:`.Index` and :class:`.UniqueConstraint` objects with the
same conditions. No warning is produced however, as we likely want to
remove the include_columns warnings for all constraints in 2.0.

In the latter case, the production of table aliases or subqueries would
fail on an FK related table not found despite the presence of
``resolve_fks=False``; the logic has been repaired so that if a related
table is not found, the :class:`.ForeignKey` object is still proxied to the
aliased table or subquery (these :class:`.ForeignKey` objects are normally
used in the production of join conditions), but it is sent with a flag that
it's not resolvable. The aliased table / subquery will then work normally,
with the exception that it cannot be used to generate a join condition
automatically, as the foreign key information is missing. This was already
the behavior for such foreign key constraints produced using non-reflection
methods, such as joining :class:`.Table` objects from different
:class:`.MetaData` collections.

Fixes: #8100
Fixes: #8101
Change-Id: Ifa37a91bd1f1785fca85ef163eec031660d9ea4d

3 years agomigrate labels to new tutorial
Mike Bayer [Sat, 4 Jun 2022 19:53:34 +0000 (15:53 -0400)] 
migrate labels to new tutorial

other org changes and some sections from old tutorial
ported to new tutorial.

Change-Id: Ic0fba60ec82fff481890887beef9ed0fa271875a

3 years agorun test_update_rowcount_return_defaults only w/ returning
Mike Bayer [Mon, 6 Jun 2022 14:58:59 +0000 (10:58 -0400)] 
run test_update_rowcount_return_defaults only w/ returning

sane_rowcount_w_returning asserts failure, which will only
occur here if the DBAPI actually uses RETURNING.

as SQLite conditionally supports RETURNING which breaks
rowcount support only if present, limit this test to that
case.

Additionally, newer pysqlites will likely fix the issue so
we will probably want to put a sqlite3_version check as well
once that fix is released.

Change-Id: I065aa181eb48363c1024550ae3622486ae0b4a6e

3 years agoMerge "Generalize RETURNING and suppor for MariaDB / SQLite" into main
mike bayer [Sun, 5 Jun 2022 20:40:41 +0000 (20:40 +0000)] 
Merge "Generalize RETURNING and suppor for MariaDB / SQLite" into main

3 years agoDocs Update - Add **kwargs to CaseInsensitiveComparator docs (#8063)
Justin Crown [Sat, 4 Jun 2022 20:10:38 +0000 (16:10 -0400)] 
Docs Update - Add **kwargs to CaseInsensitiveComparator docs (#8063)

* Add **kwargs to CaseInsensitiveComparator docs

* add kwargs to other operate examples

Change-Id: I70a1e68bca27c2355ad3b7c5bbc538027f112bd9

* missed one entry

Change-Id: Ieb4a18ab6d96e588e9ec7672cfa65fe2fd8301e5

Co-authored-by: Federico Caselli <cfederico87@gmail.com>
3 years agoMerge "Fixed orm not applying fetch" into main
mike bayer [Sat, 4 Jun 2022 18:21:02 +0000 (18:21 +0000)] 
Merge "Fixed orm not applying fetch" into main

3 years agoFixed orm not applying fetch
Federico Caselli [Fri, 3 Jun 2022 10:13:10 +0000 (12:13 +0200)] 
Fixed orm not applying fetch

Fixed an issue where :meth:`_sql.GenerativeSelect.fetch` would be
ignored when executing a statement using the ORM.

Fixes: #8091
Change-Id: I6790c7272a71278e90de2529c8bc8ae89e54e288

3 years agofix some typos (#8093)
cui fliter [Sat, 4 Jun 2022 10:16:27 +0000 (18:16 +0800)] 
fix some typos (#8093)

Signed-off-by: cuishuang <imcusg@gmail.com>
3 years agoLink to dialect for Actian Avalanche, Vector, Actian X, and Ingres (#8039)
clach04 [Sat, 4 Jun 2022 10:15:17 +0000 (03:15 -0700)] 
Link to dialect for Actian Avalanche, Vector, Actian X, and Ingres (#8039)

3 years agodocs: spelling error (#8088)
Galen Rice [Sat, 4 Jun 2022 10:07:43 +0000 (06:07 -0400)] 
docs: spelling error (#8088)

Leave off the last S for savings!

3 years agosome typing fixes
Mike Bayer [Fri, 3 Jun 2022 14:34:19 +0000 (10:34 -0400)] 
some typing fixes

* ClassVar for decl fields, add __tablename__
* dataclasses require annotations for all fields.  For us,
  if no annotation, then skip that field as part of what is
  considered to be a "dataclass", as this matches the behavior
  of pyright right now.   We could alternatively raise on this
  use, which is what dataclasses does.   we should ask the pep
  people
* plain field that's just "str", "int", etc., with no value.
  Disallow it unless __allow_unmapped__ is set.   If field
  has dataclasses.field, Column, None, a value etc, it goes through,
  and when using dataclasses mixin all such fields are considered
  for the dataclass setup just like a dataclass.  Hopefully this
  does not have major backwards compat issues.  __allow_unmapped__
  can be set on the base class, mixins, etc., it's liberal for
  now in case people have this problem.
* accommodate for ClassVar, these are not considered at all for
  mapping.

Change-Id: Id743aa0456bade9a5d5832796caeecc3dc4accb7

3 years agoemphasize expire_on_commit in detached error docs
Mike Bayer [Thu, 2 Jun 2022 18:52:27 +0000 (14:52 -0400)] 
emphasize expire_on_commit in detached error docs

issues like #8082 suggest users are still not
fully aware of the need to set this parameter
when dealing with detached objects.

Change-Id: I6f389fdbe18b9c977bfb8188fc4732dbd56884d9

3 years agoGeneralize RETURNING and suppor for MariaDB / SQLite
Daniel Black [Tue, 28 Sep 2021 18:20:06 +0000 (14:20 -0400)] 
Generalize RETURNING and suppor for MariaDB / SQLite

As almost every dialect supports RETURNING now, RETURNING
is also made more of a default assumption.

* the default compiler generates a RETURNING clause now
  when specified; CompileError is no longer raised.
* The dialect-level implicit_returning parameter now has
  no effect.   It's not fully clear if there are real world
  cases relying on the dialect-level parameter, so we will see
  once 2.0 is released.   ORM-level RETURNING can be disabled
  at the table level, and perhaps "implicit returning" should
  become an ORM-level option at some point as that's where
  it applies.
* Altered ORM update() / delete() to respect table-level
  implicit returning for fetch.
* Since MariaDB doesnt support UPDATE returning, "full_returning"
  is now split into insert_returning, update_returning, delete_returning
* Crazy new thing.  Dialects that have *both* cursor.lastrowid
  *and* returning.   so now we can pick between them for SQLite
  and mariadb.  so, we are trying to keep it on .lastrowid for
  simple inserts with an autoincrement column, this helps with
  some edge case test scenarios and i bet .lastrowid is faster
  anyway.  any return_defaults() / multiparams etc then we
  use returning
* SQLite decided they dont want to return rows that match in
  ON CONFLICT.  this is flat out wrong, but for now we need to
  work with it.

Fixes: #6195
Fixes: #7011
Closes: #7047
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7047
Pull-request-sha: d25d5ea3abe094f282c53c7dd87f5f53a9e85248

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I9908ce0ff7bdc50bd5b27722081767c31c19a950

3 years agoMerge "propagate proxy_key from WrapsColumnExpression" into main
mike bayer [Wed, 1 Jun 2022 17:27:13 +0000 (17:27 +0000)] 
Merge "propagate proxy_key from WrapsColumnExpression" into main

3 years agoMerge "add backend agnostic UUID datatype" into main
mike bayer [Wed, 1 Jun 2022 16:13:36 +0000 (16:13 +0000)] 
Merge "add backend agnostic UUID datatype" into main

3 years agopropagate proxy_key from WrapsColumnExpression
Mike Bayer [Wed, 1 Jun 2022 16:11:19 +0000 (12:11 -0400)] 
propagate proxy_key from WrapsColumnExpression

this allows cast() of a label() to propagate the
proxy key outwards in the same way that it apparently
works at the SQL level.

This is stuffing even more rules into naming so basically
seeing how far we can go without other cases starting
to fail.

Fixes: #8084
Change-Id: I20bd97dae798fee6492334c06934e807d0f269ef

3 years agoadd backend agnostic UUID datatype
Mike Bayer [Fri, 11 Feb 2022 09:54:45 +0000 (04:54 -0500)] 
add backend agnostic UUID datatype

Added new backend-agnostic :class:`_types.Uuid` datatype generalized from
the PostgreSQL dialects to now be a core type, as well as migrated
:class:`_types.UUID` from the PostgreSQL dialect. Thanks to Trevor Gross
for the help on this.

also includes:

* corrects some missing behaviors in the suite literal fixtures
  test where row round trips weren't being correctly asserted.
* fixes some of the ISO literal date rendering added in
  952383f9ee0 for #5052 to truncate datetime strings for date/time
  datatypes in the same way that drivers typically do for bound
  parameters; this was not working fully and wasn't caught by the
  broken test fixture

Fixes: #7212
Change-Id: I981ac6d34d278c18281c144430a528764c241b04

3 years agoMerge "Support handle_error for pre_ping" into main
mike bayer [Wed, 1 Jun 2022 13:58:17 +0000 (13:58 +0000)] 
Merge "Support handle_error for pre_ping" into main

3 years agocherry-pick changelog update for 1.4.38
Mike Bayer [Tue, 31 May 2022 21:28:09 +0000 (17:28 -0400)] 
cherry-pick changelog update for 1.4.38

3 years agocherry-pick changelog from 1.4.37
Mike Bayer [Tue, 31 May 2022 21:28:08 +0000 (17:28 -0400)] 
cherry-pick changelog from 1.4.37

3 years agochangelog fixes
Mike Bayer [Tue, 31 May 2022 21:21:39 +0000 (17:21 -0400)] 
changelog fixes

Change-Id: Id3fc3019f8eb799aa5adf6ca28e0aeedc0da31dd

3 years agoMerge "establish sessionmaker and async_sessionmaker as generic" into main
mike bayer [Tue, 31 May 2022 20:56:53 +0000 (20:56 +0000)] 
Merge "establish sessionmaker and async_sessionmaker as generic" into main

3 years agoMerge "Handle dead-connection errors for users of python-oracledb" into main
mike bayer [Tue, 31 May 2022 20:42:21 +0000 (20:42 +0000)] 
Merge "Handle dead-connection errors for users of python-oracledb" into main

3 years agoMerge "raise informative error when selectable can't be extended" into main
mike bayer [Tue, 31 May 2022 19:47:49 +0000 (19:47 +0000)] 
Merge "raise informative error when selectable can't be extended" into main

3 years agoUpdate declarative_styles.rst: Update code example to attrs TNG usage. (#8072)
Patrick Gerken [Tue, 31 May 2022 19:42:35 +0000 (21:42 +0200)] 
Update declarative_styles.rst: Update code example to attrs TNG usage. (#8072)

* Update declarative_styles.rst

Update docs to new style usage of attrs.
This is the default since December 2021.
While the old style still works, the newer one looks much nicer and is likely to be dominant pretty quickly. Imho.

* Update declarative_styles.rst

* Update declarative_styles.rst

3 years agoestablish sessionmaker and async_sessionmaker as generic
Mike Bayer [Thu, 26 May 2022 18:35:03 +0000 (14:35 -0400)] 
establish sessionmaker and async_sessionmaker as generic

This is so that custom Session and AsyncSession classes
can be typed for these factories.  Added appropriate
typevars to  `__call__()`, `__enter__()` and other methods
so that a custom Session or AsyncSession subclass is carried
through.

Fixes: #7656
Change-Id: Ia2b8c1f22b4410db26005c3285f6ba3d13d7f0e0

3 years agoSupport handle_error for pre_ping
Mike Bayer [Mon, 30 May 2022 16:29:58 +0000 (12:29 -0400)] 
Support handle_error for pre_ping

The :meth:`.DialectEvents.handle_error` event is now moved to the
:class:`.DialectEvents` suite from the :class:`.EngineEvents` suite, and
now participates in the connection pool "pre ping" event for those dialects
that make use of disconnect codes in order to detect if the database is
live. This allows end-user code to alter the state of "pre ping". Note that
this does not include dialects which contain a native "ping" method such as
that of psycopg2 or most MySQL dialects.

Fixes: #5648
Change-Id: I353d84a4f66f309d2467b7e67621db6b8c70411e

3 years agoraise informative error when selectable can't be extended
Mike Bayer [Tue, 31 May 2022 14:48:16 +0000 (10:48 -0400)] 
raise informative error when selectable can't be extended

An informative error is raised for the use case where
:meth:`.Insert.from_select` is being passed a "compound select" object such
as a UNION, yet the INSERT statement needs to append additional columns to
support Python-side or explicit SQL defaults from the table metadata. In
this case a subquery of the compound object should be passed.

Fixes: #8073
Change-Id: Ic4a5dbf84ec49d2451901be05cb9cf6ae93f02b7

3 years agoHandle dead-connection errors for users of python-oracledb
Christopher Jones [Tue, 31 May 2022 12:27:18 +0000 (08:27 -0400)] 
Handle dead-connection errors for users of python-oracledb

Added two new error codes for Oracle disconnect handling to support early
testing of the new "python-oracledb" driver released by Oracle.

Fixes: #8066
Closes: #8065
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8065
Pull-request-sha: d630b8457a1d29b7a1354ccc6d5e2956eea865f6

Change-Id: Ib14dbb888597b1087b1bb7c505ccad59df226177
(cherry picked from commit 2bf00472bfafd8fd0cca5b4fe55ff4faf1a1279e)
(cherry picked from commit 8564e2abf97795819f655a70b19b3bc820729c79)

3 years agorepair incorrect "cursor" var name in connection faq
Josep Pascual Badia [Mon, 30 May 2022 14:41:55 +0000 (10:41 -0400)] 
repair incorrect "cursor" var name in connection faq

Closes: #8075
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8075
Pull-request-sha: 34e5eaf3870f89c9c38ffe81121fa1b42e363752

Change-Id: Iab8cdc9f8da68ac955eea75efeba263d0a9dcb7b

3 years agoMerge "remove "deannotate" from column_property expression" into main
mike bayer [Sun, 29 May 2022 21:36:40 +0000 (21:36 +0000)] 
Merge "remove "deannotate" from column_property expression" into main

3 years agoMerge "move bindparam quote application from compiler to default" into main
mike bayer [Sun, 29 May 2022 21:34:37 +0000 (21:34 +0000)] 
Merge "move bindparam quote application from compiler to default" into main

3 years agoremove "deannotate" from column_property expression
Mike Bayer [Fri, 27 May 2022 20:07:01 +0000 (16:07 -0400)] 
remove "deannotate" from column_property expression

Fixed issue where using a :func:`_orm.column_property` construct containing
a subquery against an already-mapped column attribute would not correctly
apply ORM-compilation behaviors to the subquery, including that the "IN"
expression added for a single-table inherits expression would fail to be
included.

This fix involves a few tweaks in the ORM adaptation logic,
including a missing "parententity" adaptation on the mapper
side.  The specific mechanics here have a lot of moving parts
so we will continue to add tests to assert these cases.  In
particular a more complete test for issue #2316 is added
that was relying upon the deannotate happening here.

Fixes: #8064
Change-Id: Ia85dd12dcf6e7c002b30de4a27d7aa66cb3cd20e

3 years agomove bindparam quote application from compiler to default
Mike Bayer [Sun, 29 May 2022 16:07:46 +0000 (12:07 -0400)] 
move bindparam quote application from compiler to default

in 296c84313ab29bf9599634f3 for #5653 we generalized Oracle's
parameter escaping feature into the compiler, so that it could also
work for PostgreSQL.  The compiler used quoted names within parameter
dictionaries, which then led to the complexity that all functions
which interpreted keys from the compiled_params dict had to
also quote the param names to use the dictionary.  This
extra complexity was not added to the ORM peristence.py however,
which led to the versioning id feature being broken as well as
other areas where persistence.py relies on naming schemes present
in context.compiled_params.  It also was not added to the
"processors" lookup which led to #8053, that added this escaping
to that part of the compiler.

To both solve the whole problem as well as simplify the compiler
quite a bit, move the actual application of the escaped names
to be as late as possible, when default.py builds the final list
of parameters.  This is more similar to how it worked previously
where OracleExecutionContext would be late-applying these
escaped names.   This re-establishes context.compiled_params as
deterministically named regardless of dialect in use and moves
out the complexity of the quoted param names to be only at the
cursor.execute stage.

Fixed bug, likely a regression from 1.3, where usage of column names that
require bound parameter escaping, more concretely when using Oracle with
column names that require quoting such as those that start with an
underscore, or in less common cases with some PostgreSQL drivers when using
column names that contain percent signs, would cause the ORM versioning
feature to not work correctly if the versioning column itself had such a
name, as the ORM assumes certain bound parameter naming conventions that
were being interfered with via the quotes. This issue is related to
:ticket:`8053` and essentially revises the approach towards fixing this,
revising the original issue :ticket:`5653` that created the initial
implementation for generalized bound-parameter name quoting.

Fixes: #8056
Change-Id: I57b064e8f0d070e328b65789c30076f6a0ca0fef

3 years agomssql login failure if password starts with "{"
Gord Thompson [Sun, 29 May 2022 13:07:45 +0000 (07:07 -0600)] 
mssql login failure if password starts with "{"

Fix issue where a password with a leading "{" would
result in login failure.

Fixes: #8062
Change-Id: If91c2c211937b5eac89b8d525c22a19b0a94c5c4

3 years agoadd typing for PG UUID, other types
Mike Bayer [Fri, 27 May 2022 13:56:01 +0000 (09:56 -0400)] 
add typing for PG UUID, other types

note that UUID will be generalized into core with #7212.

Fixes: #6402
Change-Id: I90f0052ca74367c2c2f1ce2f8a90e81d173d1430

3 years agoQueryableAttribute can be used as DDL column
Mike Bayer [Thu, 26 May 2022 20:12:10 +0000 (16:12 -0400)] 
QueryableAttribute can be used as DDL column

We have a lot of mappings with like ForeignKey(A.id)
so this needs to be included.

Change-Id: I8ac4211fb09720f093fe7f6353f365ee1d7faaae

3 years agoMerge "bump bundle count" into main
mike bayer [Wed, 25 May 2022 17:09:53 +0000 (17:09 +0000)] 
Merge "bump bundle count" into main

3 years agoMerge "apply bindparam escape name to processors dictionary" into main
mike bayer [Wed, 25 May 2022 16:44:50 +0000 (16:44 +0000)] 
Merge "apply bindparam escape name to processors dictionary" into main

3 years agobump bundle count
Mike Bayer [Wed, 25 May 2022 16:40:02 +0000 (12:40 -0400)] 
bump bundle count

this count seems to have grown a bit.  can look into
the cause, but at the moment we need CI to pass.

Change-Id: Iea1e4900d5c5d3f80e7ce400a2b9cc1f313cef4c

3 years agoMerge "enable pg8000 for 1.29.1 and above" into main
mike bayer [Wed, 25 May 2022 14:12:41 +0000 (14:12 +0000)] 
Merge "enable pg8000 for 1.29.1 and above" into main