]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agosphinx conf tweaks
Mike Bayer [Fri, 15 Apr 2022 18:22:03 +0000 (14:22 -0400)] 
sphinx conf tweaks

don't put args on the class itself, as it seems
to be using __new__ in some cases which is ugly

get new zzzeeksphinx built

Change-Id: Ib1453646329569eacd282825588292b451a80f68

3 years agoupdate bake_queries documentation
Mike Bayer [Fri, 15 Apr 2022 15:11:42 +0000 (11:11 -0400)] 
update bake_queries documentation

this parameter has had no effect since 1.4.23 in #6889,
but the documentation was not updated.

Change-Id: I36f4ea6144b9fd09243f96698e7a03cd217da1e7
(cherry picked from commit 2ea124b61f0ef98d398c43299509224e9a9d77f6)

3 years agoMerge "pep484: schema API" into main
mike bayer [Fri, 15 Apr 2022 14:58:04 +0000 (14:58 +0000)] 
Merge "pep484: schema API" into main

3 years agopep484: schema API
Mike Bayer [Wed, 13 Apr 2022 13:45:29 +0000 (09:45 -0400)] 
pep484: schema API

implement strict typing for schema.py

this module has lots of public API, lots of old decisions
and very hard to follow construction sequences in many
cases, and is also where we get a lot of new feature requests,
so strict typing should help keep things clean.

among improvements here, fixed the pool .info getters
and also figured out how to get ColumnCollection and
related to be covariant so that we may set them up
as returning Column or ColumnClause without any conflicts.

DDL was affected, noting that superclasses of DDLElement
(_DDLCompiles, added recently) can now be passed into
"ddl_if" callables; reorganized ddl into ExecutableDDLElement
as a new name for DDLElement and _DDLCompiles renamed to
BaseDDLElement.

setting up strict also located an API use case that
is completely broken, which is connection.execute(some_default)
returns a scalar value.   This case has been deprecated
and new paths have been set up so that connection.scalar()
may be used.  This likely wasn't possible in previous
versions because scalar() would assume a CursorResult.

The scalar() change also impacts Session as we have explicit
support (since someone had reported it as a regression)
for session.execute(Sequence()) to work.  They will get the
same deprecation message (which omits the word "Connection",
just uses ".execute()" and ".scalar()") and they can then
use Session.scalar() as well.  Getting this to type
correctly while still supporting ORM use cases required
some refactoring, and I also set up a keyword only delimeter
for Session.execute() and related as execution_options /
bind_arguments should always be keyword only, applied these
changes to AsyncSession as well.

Additionally simpify Table __init__ now that we are Python
3 only, we can have positional plus explicit kwargs finally.
Simplify Column.__init__ as well again taking advantage
of kw only arguments.

Fill in most/all __init__ methods in sqltypes.py as
the constructor for types is most of the API.   should
likely do this for dialect-specific types as well.

Apply _InfoType for all info attributes as should have been
done originally and update descriptor decorators.

Change-Id: I3f9f8ff3f1c8858471ff4545ac83d68c88107527

3 years agoFix link to RFC 1738 (#7935)
Sergey Golitsynskiy [Thu, 14 Apr 2022 20:01:26 +0000 (16:01 -0400)] 
Fix link to RFC 1738 (#7935)

3 years agoEnsure ORMInsert sets up bind state
Mike Bayer [Thu, 14 Apr 2022 16:01:16 +0000 (12:01 -0400)] 
Ensure ORMInsert sets up bind state

Fixed regression where the change in #7861, released in version 1.4.33,
that brought the :class:`.Insert` construct to be partially recognized as
an ORM-enabled statement did not properly transfer the correct mapper /
mapped table state to the :class:`.Session`, causing the
:meth:`.Session.get_bind` method to fail for a :class:`.Session` that was
bound to engines and/or connections using the :paramref:`.Session.binds`
parameter.

Fixes: #7936
Change-Id: If19edef8e2dd68335465429eb3d2f0bfdade4a4c

3 years agoupdate Numeric/Float docstrings
Mike Bayer [Thu, 14 Apr 2022 13:59:11 +0000 (09:59 -0400)] 
update Numeric/Float docstrings

These docs were very out of date re: cdecimal.   Additionally,
as pointed out in #5252, the Numeric documentation is misleading;
SQLAlchemy's Numeric hierarchy resembles more of the Oracle
approach where precision and scale solely determine the kind of
datatype being worked with.   Float is essentially Numeric with
different defaults.

Fixes: #5252
Change-Id: I661109fabf04ba7831c7ddafba15321dd445ea5d

3 years agoMerge "implement multi-element expression constructs" into main
mike bayer [Thu, 14 Apr 2022 12:38:43 +0000 (12:38 +0000)] 
Merge "implement multi-element expression constructs" into main

3 years agoMerge "Fix psycopg2 pre_ping with autocommit" into main
mike bayer [Wed, 13 Apr 2022 21:21:59 +0000 (21:21 +0000)] 
Merge "Fix psycopg2 pre_ping with autocommit" into main

3 years agoimplement multi-element expression constructs
Mike Bayer [Tue, 12 Apr 2022 17:52:31 +0000 (13:52 -0400)] 
implement multi-element expression constructs

Improved the construction of SQL binary expressions to allow for very long
expressions against the same associative operator without special steps
needed in order to avoid high memory use and excess recursion depth. A
particular binary operation ``A op B`` can now be joined against another
element ``op C`` and the resulting structure will be "flattened" so that
the representation as well as SQL compilation does not require recursion.

To implement this more cleanly, the biggest change here is that
column-oriented lists of things are broken away from ClauseList
in a new class ExpressionClauseList, that also forms the basis
of BooleanClauseList. ClauseList is still used for the generic
"comma-separated list" of things such as Tuple and things like
ORDER BY, as well as in some API endpoints.

Also adds __slots__ to the TypeEngine-bound Comparator
classes.   Still can't really do __slots__ on ClauseElement.

Fixes: #7744
Change-Id: I81a8ceb6f8f3bb0fe52d58f3cb42e4b6c2bc9018

3 years agoFix psycopg2 pre_ping with autocommit
Federico Caselli [Mon, 11 Apr 2022 21:19:16 +0000 (23:19 +0200)] 
Fix psycopg2 pre_ping with autocommit

Fixed an issue what would cause autocommit mode to be reset
when using pre_ping in conjunction engine level autocommit
on the psycopg2 driver.

Fixes: #7930
Change-Id: I4cccaf1b7f8cbacd853689458080784114fcc390

3 years agoMerge "read from cls.__dict__ so init_subclass works" into main
mike bayer [Wed, 13 Apr 2022 16:42:29 +0000 (16:42 +0000)] 
Merge "read from cls.__dict__ so init_subclass works" into main

3 years agoread from cls.__dict__ so init_subclass works
Mike Bayer [Mon, 4 Apr 2022 23:01:54 +0000 (19:01 -0400)] 
read from cls.__dict__ so init_subclass works

Modified the :class:`.DeclarativeMeta` metaclass to pass ``cls.__dict__``
into the declarative scanning process to look for attributes, rather than
the separate dictionary passed to the type's ``__init__()`` method. This
allows user-defined base classes that add attributes within an
``__init_subclass__()`` to work as expected, as ``__init_subclass__()`` can
only affect the ``cls.__dict__`` itself and not the other dictionary. This
is technically a regression from 1.3 where ``__dict__`` was being used.

Additionally makes the reference between ClassManager and
the declarative configuration object a weak reference, so that it
can be discarded after mappers are set up.

Fixes: #7900
Change-Id: I3c2fd4e227cc1891aa4bb3d7d5b43d5686f9f27c

3 years agoDon't pass vistor to immutables in cloned traverse
Mike Bayer [Tue, 12 Apr 2022 13:41:55 +0000 (09:41 -0400)] 
Don't pass vistor to immutables in cloned traverse

Saw someone using cloned_traverse to move columns around
(changing their .table) and not surprisingly having poor results.
As cloned traversal is to provide a hook for in-place mutation
of elements, it should not be given Immutable objects as these
should not be changed once they are structurally composed.

Change-Id: I43b22f52f243ef481a75d2cf5ecc73d50f110a81

3 years agopep-484: asyncio
Mike Bayer [Sun, 10 Apr 2022 19:42:35 +0000 (15:42 -0400)] 
pep-484: asyncio

in this patch the asyncio/events.py module, which
existed only to raise errors when trying to attach event
listeners, is removed, as we were already coding an asyncio-specific
workaround in upstream Pool / Session to raise this error,
just moved the error out to the target and did the same thing
for Engine.

We also add an async_sessionmaker class.  The initial rationale
here is because sessionmaker() is hardcoded to Session subclasses,
and there's not a way to get the use case of
sessionmaker(class_=AsyncSession) to type correctly without changing
the sessionmaker() symbol itself to be a function and not a class,
which gets too complicated for what this is. Additionally,
_SessionClassMethods has only three methods on it, one of which
is not usable with asyncio (close_all()), the others
not generally used from the session class.

Change-Id: I064a5fa5d91cc8d5bbe9597437536e37b4e801fe

3 years agopep-484: session, instancestate, etc
Mike Bayer [Thu, 7 Apr 2022 16:37:23 +0000 (12:37 -0400)] 
pep-484: session, instancestate, etc

Also adds some fixes to annotation-based mapping
that have come up, as well as starts to add more
pep-484 test cases

Change-Id: Ia722bbbc7967a11b23b66c8084eb61df9d233fee

3 years agouse code generation for scoped_session
Mike Bayer [Tue, 5 Apr 2022 23:00:19 +0000 (19:00 -0400)] 
use code generation for scoped_session

our decorator thing generates code in any case,
so point it at the file itself to generate real code
for the blocks rather than doing things dynamically.

this will allow typing tools to have no problem
whatsoever and we also reduce import time overhead.
file size will be a lot bigger though, shrugs.

syntax / dupe method / etc. checking will be accomplished
by our existing linting / typing / formatting tools.

As we are also using "from __future__ import annotations",
we also no longer have to apply quotes to generated
annotations.

Change-Id: I20962cb65bda63ff0fb67357ab346e9b1ef4f108

3 years agolevel up pep-484 on engine result
Mike Bayer [Mon, 11 Apr 2022 14:54:42 +0000 (10:54 -0400)] 
level up pep-484 on engine result

Have each result subclass be generic to the
kind of row/object it returns.  rework things so that
a significant number of "type ignores" can go away
and also allow asyncio to more cleanly proxy
the result objects.

Change-Id: Ia3ddb2cb52f5856839bd8c9c46f0289ab4b10405

3 years agorepair ancient and incorrect comment
Mike Bayer [Tue, 12 Apr 2022 02:03:28 +0000 (22:03 -0400)] 
repair ancient and incorrect comment

it referred towards _columntoproperty refering to
lists of MapperProperty.  this comment goes all the
way to pre 0.1 being released.   it's likely been
wrong for nearly all that time.

Change-Id: I71234ae58a6253249d92224356e38372e4aff148

3 years agoupdate flake8 noqa skips with proper syntax
Federico Caselli [Mon, 11 Apr 2022 20:21:20 +0000 (22:21 +0200)] 
update flake8 noqa skips with proper syntax

Change-Id: I42ed77f559e3ee5b8c600d98457ee37803ef0ea6

3 years agosimplify coverage config
Mike Bayer [Sat, 9 Apr 2022 15:32:50 +0000 (11:32 -0400)] 
simplify coverage config

I *think* we don't need to tell .coverage to look in lib,
it seems to be covering from whereever successfuly.  not
sure, but want to run on jenkins to see how it comes out.

Change-Id: Ib74f427a5b09fcbeba0188dcf02dab27c329a8cd

3 years agoadd mypy coverage task
Mike Bayer [Sat, 9 Apr 2022 15:15:29 +0000 (11:15 -0400)] 
add mypy coverage task

get mypy plugin to be able to have coverage

Change-Id: I8c2d57bb97bd522b83d20a0f97576c7ae9ea71a5

3 years agoMerge "add sane_rowcount to SimpleUpdateDeleteTest" into main
mike bayer [Sat, 9 Apr 2022 14:21:28 +0000 (14:21 +0000)] 
Merge "add sane_rowcount to SimpleUpdateDeleteTest" into main

3 years agoupdate DDL examples removing execute_if
Mike Bayer [Sat, 9 Apr 2022 14:02:35 +0000 (10:02 -0400)] 
update DDL examples removing execute_if

Fixes: #7924
Change-Id: I684bf3720010ffe34dbdd39ec8c7e0c4af94e620

3 years agoadd sane_rowcount to SimpleUpdateDeleteTest
Mike Bayer [Sat, 9 Apr 2022 13:50:18 +0000 (09:50 -0400)] 
add sane_rowcount to SimpleUpdateDeleteTest

For third party dialects, repaired a missing requirement for the
``SimpleUpdateDeleteTest`` suite test which was not checking for a working
"rowcount" function on the target dialect.

Fixes: #7919
Change-Id: I2bc68132131eb36c43b8dabec0fac86272e26df5

3 years agoimplement iso date literals for all backends
Mike Bayer [Mon, 28 Mar 2022 17:29:23 +0000 (13:29 -0400)] 
implement iso date literals for all backends

Added modified ISO-8601 rendering (i.e. ISO-8601 with the T converted to a
space) when using ``literal_binds`` with the SQL compilers provided by the
PostgreSQL, MySQL, MariaDB, MSSQL, Oracle dialects. For Oracle, the ISO
format is wrapped inside of an appropriate TO_DATE() function call.
Previously this rendering was not implemented for dialect-specific
compilation.

Fixes: #5052
Change-Id: I7af15a51fedf5c5a8e76e645f7c3be997ece35f0

3 years agoi forgot about begin_nested()
Mike Bayer [Fri, 8 Apr 2022 14:56:54 +0000 (10:56 -0400)] 
i forgot about begin_nested()

make bulleted lists of what is autoflush and what's not.

Change-Id: Id3bc4714013e9df243d804d7b5b60c6ef75e1316

3 years agoclarify autoflush setting does not apply to commit
Mike Bayer [Fri, 8 Apr 2022 14:36:50 +0000 (10:36 -0400)] 
clarify autoflush setting does not apply to commit

Change-Id: Icad0f3bd071422b8d1af204c9a1193a9ce6124ba
References: #7916

3 years agoupdate comment re: #2703
Mike Bayer [Fri, 8 Apr 2022 13:48:26 +0000 (09:48 -0400)] 
update comment re: #2703

Change-Id: Ia78db7601e98acd2562872e0fda639aac99650dd

3 years agoexplicitly refer to Apple M1 for greenlet issue
Mike Bayer [Fri, 8 Apr 2022 13:28:47 +0000 (09:28 -0400)] 
explicitly refer to Apple M1 for greenlet issue

As developers are now buying lots of Apple M1
machines, and AFAWK greenlet is still not able
to provide a pre-built wheel, we are going to get a lot
of devs trying to use asyncio on their Apple M1s, in
greater proportions compared to devs running containers
etc. on other various less popular CPU architectures.

Add a new FAQ section for installation, add new
red dragon to the very top of asyncio docs,
add new verbiage, all of which includes
"Apple M1" in bold text, to minimize the chance of anyone
missing this.

Fixes: #7922
Fixes: #7714
Change-Id: I106923a2860a4efd77d1b999197be102afc1f73d

3 years agoMerge "cx_Oracle modernize" into main
mike bayer [Thu, 7 Apr 2022 15:19:10 +0000 (15:19 +0000)] 
Merge "cx_Oracle modernize" into main

3 years agocx_Oracle modernize
Mike Bayer [Mon, 4 Apr 2022 14:13:23 +0000 (10:13 -0400)] 
cx_Oracle modernize

Full "RETURNING" support is implemented for the cx_Oracle dialect, meaning
multiple RETURNING rows are now recived for DML statements that produce
more than one row for RETURNING.

cx_Oracle 7 is now the minimum version for cx_Oracle.

Getting Oracle to do multirow returning took about 5 minutes.  however,
getting Oracle's RETURNING system to integrate with ORM-enabled
insert, update, delete, is a big deal because that architecture wasn't
really working very robustly, including some recent changes in 1.4
for FromStatement were done in a hurry, so this patch also cleans up
the FromStatement situation and begins to establish it more concretely
as the base for all ReturnsRows / TextClause ORM scenarios.

Fixes: #6245
Change-Id: I2b4e6007affa51ce311d2d5baa3917f356ab961f

3 years agocherry-pick changelog update for 1.4.36
Mike Bayer [Wed, 6 Apr 2022 15:34:25 +0000 (11:34 -0400)] 
cherry-pick changelog update for 1.4.36

3 years agocherry-pick changelog from 1.4.35
Mike Bayer [Wed, 6 Apr 2022 15:34:24 +0000 (11:34 -0400)] 
cherry-pick changelog from 1.4.35

3 years agoclassify issue
Mike Bayer [Wed, 6 Apr 2022 15:17:05 +0000 (11:17 -0400)] 
classify issue

Change-Id: Id1e59fee382d1d72d78e99b1c56a5837b5503fed

3 years agomaintain complete cloned_set for BindParameter
Mike Bayer [Wed, 6 Apr 2022 13:41:11 +0000 (09:41 -0400)] 
maintain complete cloned_set for BindParameter

Fixed regression caused by :ticket:`7823` which impacted the caching
system, such that bound parameters that had been "cloned" within ORM
operations, such as polymorphic loading, would in some cases not acquire
their correct execution-time value leading to incorrect bind values being
rendered.

Fixes: #7903
Change-Id: I61c802749b859bebeb127d24e66d6e77d13ce57a

3 years agofix typo in lambda example
Mike Bayer [Tue, 5 Apr 2022 18:39:32 +0000 (14:39 -0400)] 
fix typo in lambda example

we might have an actual customer so clean up shop

Change-Id: I0b1e36ad78f364805a3a7bfd6fac953cf94b838f

3 years agopep484 - sql.selectable
Mike Bayer [Wed, 30 Mar 2022 22:01:58 +0000 (18:01 -0400)] 
pep484 - sql.selectable

the pep484 task becomes more intense as there is mounting
pressure to come up with a consistency in how data moves
from end-user to instance variable.

current thinking is coming into:

1. there are _typing._XYZArgument objects that represent "what the
   user sent"
2. there's the roles, which represent a kind of "filter" for different
   kinds of objects.   These are mostly important as the argument
   we pass to coerce().
3. there's the thing that coerce() returns, which should be what the
   construct uses as its internal representation of the thing.
   This is _typing._XYZElement.

but there's some controversy over whether or
not we should pass actual ClauseElements around by their role
or not.   I think we shouldn't at the moment, but this makes the
"role-ness" of something a little less portable. Like, we have
to set DMLTableRole for TableClause, Join, and Alias, but then
also we have to repeat those three types in order to set up
_DMLTableElement.

Other change introduced here, there was a deannotate=True
for the left/right of a sql.join().    All tests pass without that.
I'd rather not have that there as if we have a join(A, B) where
A, B are mapped classes, we want them inside of the _annotations.
The rationale seems to be performance, but this performance can
be illustrated to be on the compile side which we hope is cached
in the normal case.

CTEs now accommodate for text selects including recursive.

Get typing to accommodate "util.preloaded" cleanly; add "preloaded"
as a real module.  This seemed like we would have needed
pep562 `__getattr__()` but we don't, just set names in
globals() as we import them.

References: #6810
Change-Id: I34d17f617de2fe2c086fc556bd55748dc782faf0

3 years agoMerge "use .fromisoformat() for sqlite datetime, date, time parsing" into main
mike bayer [Sun, 3 Apr 2022 19:20:32 +0000 (19:20 +0000)] 
Merge "use .fromisoformat() for sqlite datetime, date, time parsing" into main

3 years agouse .fromisoformat() for sqlite datetime, date, time parsing
Mike Bayer [Sun, 3 Apr 2022 17:44:57 +0000 (13:44 -0400)] 
use .fromisoformat() for sqlite datetime, date, time parsing

SQLite datetime, date, and time datatypes now use Python standard lib
``fromisoformat()`` methods in order to parse incoming datetime, date, and
time string values. This improves performance vs. the previous regular
expression-based approach, and also automatically accommodates for datetime
and time formats that contain either a six-digit "microseconds" format or a
three-digit "milliseconds" format.

Fixes: #7029
Change-Id: I67aab4fe5ee3055e5996050cf4564981413cc221

3 years agoTableValuedAlias generation fixes
Mike Bayer [Sun, 3 Apr 2022 15:28:57 +0000 (11:28 -0400)] 
TableValuedAlias generation fixes

Fixed bug in newly implemented
:paramref:`.FunctionElement.table_valued.joins_implicitly` feature where
the parameter would not automatically propagate from the original
:class:`.TableValuedAlias` object to the secondary object produced when
calling upon :meth:`.TableValuedAlias.render_derived` or
:meth:`.TableValuedAlias.alias`.

Additionally repaired these issues in :class:`.TableValuedAlias`:

* repaired a potential memory issue which could occur when
repeatedly calling :meth:`.TableValuedAlias.render_derived` against
successive copies of the same object (for .alias(), we currently
have to still continue chaining from the previous element.  not sure
if this can be improved but this is standard behavior for .alias()
elsewhere)
* repaired issue where the individual element types would be lost when
calling upon :meth:`.TableValuedAlias.render_derived` or
:meth:`.TableValuedAlias.alias`.

Fixes: #7890
Change-Id: Ie5120c7ff1e5c1bba5aaf77c782a51c637860208

3 years agoclarify alternative mapping example
Mike Bayer [Sun, 3 Apr 2022 14:39:19 +0000 (10:39 -0400)] 
clarify alternative mapping example

this second example is not part of the doctest steps,
clarify that it's not part of code examples to be present
in execution steps.   Add an extra registry +
declarative base on top
so that even if someone does run it, the Base will have
been reset and the examples will continue to work
(noting that column order in statements may change, but
probably nothing else).

Fixes: #7891
Change-Id: Icb1ba310230841e502185d9d0cadd3c18d467292

3 years agofix small indentation typo (#7882)
Maple [Sun, 3 Apr 2022 09:30:08 +0000 (17:30 +0800)] 
fix small indentation typo (#7882)

3 years agocherry-pick changelog update for 1.4.35
Mike Bayer [Thu, 31 Mar 2022 22:28:33 +0000 (18:28 -0400)] 
cherry-pick changelog update for 1.4.35

3 years agocherry-pick changelog from 1.4.34
Mike Bayer [Thu, 31 Mar 2022 22:28:33 +0000 (18:28 -0400)] 
cherry-pick changelog from 1.4.34

3 years agoallow executemany values for ON CONFLICT DO NOTHING
Mike Bayer [Thu, 31 Mar 2022 20:53:43 +0000 (16:53 -0400)] 
allow executemany values for ON CONFLICT DO NOTHING

Scaled back a fix made for :ticket:`6581` where "executemany values" mode
for psycopg2 were disabled for all "ON CONFLICT" styles of INSERT, to
not apply to the "ON CONFLICT DO NOTHING" clause, which does not include
any parameters and is safe for "executemany values" mode.  "ON CONFLICT
DO UPDATE" is still blocked from "executemany values" as there may
be additional parameters in the DO UPDATE clause that cannot be batched
(which is the original issue fixed by :ticket:`6581`).

Fixes: #7880
Change-Id: Id3e23a0c6699333409a50148fa8923cb8e564bdc

3 years agoadd template methods for ORMInsert
Mike Bayer [Thu, 31 Mar 2022 18:56:52 +0000 (14:56 -0400)] 
add template methods for ORMInsert

Fixed regression caused by :ticket:`7861` where invoking an
:class:`.Insert` construct which contained ORM entities via
:meth:`_orm.Session.execute` would fail.

Fixes: #7878
Change-Id: Icc4d8028249cc417f504fdd3e31e206b5bbc89f8

3 years agocherry-pick changelog update for 1.4.34
Mike Bayer [Thu, 31 Mar 2022 14:38:05 +0000 (10:38 -0400)] 
cherry-pick changelog update for 1.4.34

3 years agocherry-pick changelog from 1.4.33
Mike Bayer [Thu, 31 Mar 2022 14:38:05 +0000 (10:38 -0400)] 
cherry-pick changelog from 1.4.33

3 years agoMerge "add close=False parameter to engine.dispose()" into main
mike bayer [Thu, 31 Mar 2022 14:05:09 +0000 (14:05 +0000)] 
Merge "add close=False parameter to engine.dispose()" into main

3 years agoadd close=False parameter to engine.dispose()
Mike Bayer [Thu, 31 Mar 2022 13:08:11 +0000 (09:08 -0400)] 
add close=False parameter to engine.dispose()

Added new parameter :paramref:`.Engine.dispose.close`, defaulting to True.
When False, the engine disposal does not touch the connections in the old
pool at all, simply dropping the pool and replacing it. This use case is so
that when the original pool is transferred from a parent process, the
parent process may continue to use those connections.

Fixes: #7877
Change-Id: I88b0808442381ba5e50674787cdb64f0e77d8b54

3 years agoUpdate bindparam cache key
Federico Caselli [Wed, 30 Mar 2022 20:50:18 +0000 (22:50 +0200)] 
Update bindparam cache key

The ``literal_execute`` parameter now takes part of the cache
generation of a bindparam, since it changes the sql string generated
by the compiler.
Previously the correct bind values were used, but the ``literal_execute``
would be ignored on subsequent executions of the same query.

Fixes: #7876
Change-Id: I6bf887f1a2fe31f9d0ab68f5b4ff315004d006b2

3 years agoMerge "Add links to database url section from URL docs" into main
mike bayer [Wed, 30 Mar 2022 21:02:59 +0000 (21:02 +0000)] 
Merge "Add links to database url section from URL docs" into main

3 years agoMerge "pep-484: the pep-484ening, SQL part three" into main
mike bayer [Wed, 30 Mar 2022 18:36:52 +0000 (18:36 +0000)] 
Merge "pep-484: the pep-484ening, SQL part three" into main

3 years agopep-484: the pep-484ening, SQL part three
Mike Bayer [Fri, 25 Mar 2022 21:08:48 +0000 (17:08 -0400)] 
pep-484: the pep-484ening, SQL part three

hitting DML which is causing us to open up the
ColumnCollection structure a bit, as we do put anonymous
column expressions with None here.  However, we still want
Table /TableClause to have named column collections that
don't return None, so parametrize the "key" in this
collection also.

* rename some "immutable" elements to "readonly".  we change
  the contents of immutablecolumncollection underneath, so it's
  not "immutable"

Change-Id: I2593995a4e5c6eae874bed5bf76117198be8ae97

3 years agofurther changelog / doc fixes
Mike Bayer [Wed, 30 Mar 2022 15:44:23 +0000 (11:44 -0400)] 
further changelog / doc fixes

Change-Id: I959f242272ff5147b7c1f721cf119d09309a8c57

3 years agodont use cyext for sphinx builds
Mike Bayer [Wed, 30 Mar 2022 15:40:21 +0000 (11:40 -0400)] 
dont use cyext for sphinx builds

if these files are stale, imports fail and the build
silently excludes docstrings.  also , typing / docstrings
are generally in the _py version of things, so just
don't include cyexts in doc builds.

Change-Id: Ibec927c7646d4b870a84a297d1b199ccecf3afef

3 years agochangelog fixes
Mike Bayer [Wed, 30 Mar 2022 14:52:29 +0000 (10:52 -0400)] 
changelog fixes

Change-Id: I24e3de82d656d59719fd067bc81b2948e725b487

3 years agoAdd links to database url section from URL docs
Federico Caselli [Tue, 29 Mar 2022 20:49:47 +0000 (22:49 +0200)] 
Add links to database url section from URL docs

Change-Id: Ifa6dc14bf95762b9477560f485f43efa11af421b

3 years agoFix spacing on ``bindparam`` docs
Federico Caselli [Tue, 29 Mar 2022 20:51:43 +0000 (22:51 +0200)] 
Fix spacing on ``bindparam`` docs

Change-Id: I9daad5293a4887734f14e6e5de6014aca415453c

3 years agoMerge "Remove "autoload" references in Table docs" into main
mike bayer [Tue, 29 Mar 2022 20:04:29 +0000 (20:04 +0000)] 
Merge "Remove "autoload" references in Table docs" into main

3 years agoMerge "use annotated entity when adding secondary" into main
mike bayer [Tue, 29 Mar 2022 17:56:29 +0000 (17:56 +0000)] 
Merge "use annotated entity when adding secondary" into main

3 years agoRemove "autoload" references in Table docs
Gord Thompson [Mon, 28 Mar 2022 15:38:38 +0000 (09:38 -0600)] 
Remove "autoload" references in Table docs

Replace with "autoload_with" as appropriate.

Change-Id: I8bb2a7e40f116e8e5dea2b8e25d0c160bb6da94e

3 years agouse annotated entity when adding secondary
Mike Bayer [Tue, 29 Mar 2022 13:48:24 +0000 (09:48 -0400)] 
use annotated entity when adding secondary

Fixed regression in "dynamic" loader strategy where the
:meth:`_orm.Query.filter_by` method would not be given an appropriate
entity to filter from, in the case where a "secondary" table were present
in the relationship being queried and the mapping were against something
complex such as a "with polymorphic".

Fixes: #7868
Change-Id: I3b82eec6485c5a92b56a596da0cfb009e9e67883

3 years agoMerge "apply loader criteria more specifically when refresh is true" into main
mike bayer [Tue, 29 Mar 2022 14:05:12 +0000 (14:05 +0000)] 
Merge "apply loader criteria more specifically when refresh is true" into main

3 years agoMerge "fix quotes regexp for SQLite CHECK constraints" into main
mike bayer [Mon, 28 Mar 2022 22:47:09 +0000 (22:47 +0000)] 
Merge "fix quotes regexp for SQLite CHECK constraints" into main

3 years agoapply loader criteria more specifically when refresh is true
Mike Bayer [Mon, 28 Mar 2022 22:39:19 +0000 (18:39 -0400)] 
apply loader criteria more specifically when refresh is true

Fixed bug in :func:`_orm.with_loader_criteria` function where loader
criteria would not be applied to a joined eager load that were invoked
within the scope of a refresh operation for the parent object.

Fixes: #7862
Change-Id: If1ac86eaa95880b5ec5bdeee292d6e8000aac705

3 years agocolumn_descriptions or equiv for DML, core select
Mike Bayer [Sat, 26 Mar 2022 20:20:34 +0000 (16:20 -0400)] 
column_descriptions or equiv for DML, core select

Added new attributes :attr:`.ValuesBase.returning_column_descriptions` and
:attr:`.ValuesBase.entity_description` to allow for inspection of ORM
attributes and entities that are installed as part of an :class:`.Insert`,
:class:`.Update`, or :class:`.Delete` construct. The
:attr:`.Select.column_descriptions` accessor is also now implemented for
Core-only selectables.

Fixes: #7861
Change-Id: Ia6a1cd24c798ba61f4e8e8eac90a0fd00d738342

3 years agofix quotes regexp for SQLite CHECK constraints
Mike Bayer [Mon, 28 Mar 2022 17:46:24 +0000 (13:46 -0400)] 
fix quotes regexp for SQLite CHECK constraints

Fixed bug where the name of CHECK constraints under SQLite would not be
reflected if the name were created using quotes, as is the case when the
name uses mixed case or special characters.

Fixes: #5463
Change-Id: Ic3b1e0a0385fb9e727b0880e90815ea2814df313

3 years agobump black to 22.3.0
Mike Bayer [Mon, 28 Mar 2022 19:52:27 +0000 (15:52 -0400)] 
bump black to 22.3.0

both black and click were released in the past
few hours, and black 21.5b1 seems to suddenly
be failing on a missing symbol from click.  just
update to the latest

Change-Id: Idf76732479a264f7f2245699a6bdaff018e3a123

3 years agoblock asyncmy 0.2.4
Mike Bayer [Mon, 28 Mar 2022 15:23:39 +0000 (11:23 -0400)] 
block asyncmy 0.2.4

asyncmy made a backwards incompatible change to the
TIME datatype in 0.2.4 which hopefully will be reverted
as this change does not belong in a minor point release

Change-Id: Id8bf932d70f52caba06094308a5b87387e69b94b
References: https://github.com/long2ice/asyncmy/issues/37

3 years agosupport BLANK_SCHEMA, RETAIN_SCHEMA FK schema on copy
Mike Bayer [Sat, 26 Mar 2022 14:09:10 +0000 (10:09 -0400)] 
support BLANK_SCHEMA, RETAIN_SCHEMA FK schema on copy

Added support so that the :paramref:`.Table.tometadata.referred_schema_fn`
callable passed to :meth:`.Table.to_metadata` may return the value
:data:`.BLANK_SCHEMA` to indicate that the referenced foreign key should be
reset to None. The :data.`RETAIN_SCHEMA` symbol may also be returned from
this function to indicate "no change", which will behave the same as
``None`` currently does which also indicates no change.

Fixes: #7860
Change-Id: I82a45988d534295d8356453f68001b21d4ff706d

3 years agoMerge "generalize conditional DDL throughout schema / DDL" into main
mike bayer [Fri, 25 Mar 2022 19:35:32 +0000 (19:35 +0000)] 
Merge "generalize conditional DDL throughout schema / DDL" into main

3 years agogeneralize conditional DDL throughout schema / DDL
Mike Bayer [Thu, 27 Jan 2022 20:07:17 +0000 (15:07 -0500)] 
generalize conditional DDL throughout schema / DDL

Expanded on the "conditional DDL" system implemented by the
:class:`_schema.DDLElement` class to be directly available on
:class:`_schema.SchemaItem` constructs such as :class:`_schema.Index`,
:class:`_schema.ForeignKeyConstraint`, etc. such that the conditional logic
for generating these elements is included within the default DDL emitting
process. This system can also be accommodated by a future release of
Alembic to support conditional DDL elements within all schema-management
systems.

Fixes: #7631
Change-Id: I9457524d7f66f49696187cf7d2b37dbb44f0e20b

3 years agoMerge "pep484 - SQL internals" into main
mike bayer [Thu, 24 Mar 2022 21:30:52 +0000 (21:30 +0000)] 
Merge "pep484 - SQL internals" into main

3 years agoMerge "Clarify associationproxy.rst examples by using a one word keyword" into main
mike bayer [Thu, 24 Mar 2022 21:13:29 +0000 (21:13 +0000)] 
Merge "Clarify associationproxy.rst examples by using a one word keyword" into main

3 years agoClarify associationproxy.rst examples by using a one word keyword
aathan [Wed, 23 Feb 2022 22:06:42 +0000 (17:06 -0500)] 
Clarify associationproxy.rst examples by using a one word keyword

The examples are based on a `keyword` attribute but use a value
that a human may interpret as multiple keywords.

Closes: #7582
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7582
Pull-request-sha: 18b027035ece587c8bfbecff5a96385bf908edca

Change-Id: I30e8c3c0f46c66058131dfadd2b70959913a6335

3 years agopep484 - SQL internals
Mike Bayer [Sun, 20 Mar 2022 20:39:36 +0000 (16:39 -0400)] 
pep484 - SQL internals

non-strict checking for mostly internal or semi-internal
code

Change-Id: Ib91b47f1a8ccc15e666b94bad1ce78c4ab15b0ec

3 years agoMerge "more autocommit messaging" into main
mike bayer [Thu, 24 Mar 2022 18:53:34 +0000 (18:53 +0000)] 
Merge "more autocommit messaging" into main

3 years agomore autocommit messaging
Mike Bayer [Thu, 24 Mar 2022 17:58:20 +0000 (13:58 -0400)] 
more autocommit messaging

Further clarified connection-level logging to indicate the BEGIN, ROLLBACK
and COMMIT log messages do not actually indicate a real transaction when
the AUTOCOMMIT isolation level is in use; messaging has been extended to
include the BEGIN message itself, and the messaging has also been fixed to
accommodate when the :class:`.Engine` level
:paramref:`.create_engine.isolation_level` parameter was used directly.

Fixes: #7853
Change-Id: Iafc78070737ad117f84262e4bde84b81a81e4ea1

3 years agoMerge "Add option to disable from linting for table valued function" into main
mike bayer [Wed, 23 Mar 2022 16:59:30 +0000 (16:59 +0000)] 
Merge "Add option to disable from linting for table valued function" into main

3 years agoMerge "trust user PK argument as given; don't reduce" into main
mike bayer [Wed, 23 Mar 2022 16:58:12 +0000 (16:58 +0000)] 
Merge "trust user PK argument as given; don't reduce" into main

3 years agotrust user PK argument as given; don't reduce
Mike Bayer [Wed, 23 Mar 2022 00:14:04 +0000 (20:14 -0400)] 
trust user PK argument as given; don't reduce

Fixed issue where the :class:`_orm.Mapper` would reduce a user-defined
:paramref:`_orm.Mapper.primary_key` argument too aggressively, in the case
of mapping to a ``UNION`` where for some of the SELECT entries, two columns
are essentially equivalent, but in another, they are not, such as in a
recursive CTE. The logic here has been changed to accept a given
user-defined PK as given, where columns will be related to the mapped
selectable but no longer "reduced" as this heuristic can't accommodate for
all situations.

Fixes: #7842
Change-Id: Ie46f0a3d42cae0501641fa213da0a9d5ca26c3ad

3 years agoAdd option to disable from linting for table valued function
Mike Bayer [Wed, 23 Mar 2022 14:07:13 +0000 (10:07 -0400)] 
Add option to disable from linting for table valued function

Added new parameter
:paramref:`.FunctionElement.table_valued.joins_implicitly`, for the
:meth:`.FunctionElement.table_valued` construct. This parameter indicates
that the given table-valued function implicitly joins to the table it
refers towards, essentially disabling the "from linting" feature, i.e. the
"cartesian product" warning, from taking effect due to the presence of this
parameter. May be used for functions such as ``func.json_each()``.

Fixes: #7845
Change-Id: I80edcb74efbd4417172132c0db4d9c756fdd5eae

3 years agofix generate series example
Mike Bayer [Wed, 23 Mar 2022 14:09:18 +0000 (10:09 -0400)] 
fix generate series example

this just drove me nuts because it didn't include
render_derived(), doesn't run on PG as given

Change-Id: I5d39336231c97b6cd5477644a718282709db2e1f

3 years agoUpgrade parts of the documentation to 2.0 style
provinzkraut [Tue, 22 Mar 2022 17:17:56 +0000 (13:17 -0400)] 
Upgrade parts of the documentation to 2.0 style

<!-- Provide a general summary of your proposed changes in the Title field above -->

I've started to work on #7659, implementing the low hanging fruit changes for now. Some still remain, which I've outlined as a [comment](https://github.com/sqlalchemy/sqlalchemy/issues/7659#issuecomment-1073029151), and probably also some that I didn't catch.

<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [x] 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.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #7829
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7829
Pull-request-sha: a89561dd0c96c2f9a6d992fa0fb94683afaf7e30

Change-Id: Ibc5ea94b5c4b2d7b1cf7bea24f4394d1fde749be

3 years agoMerge branch 'abitrolly-patch-1'
Mike Bayer [Tue, 22 Mar 2022 13:57:14 +0000 (09:57 -0400)] 
Merge branch 'abitrolly-patch-1'

Change-Id: I049baded97844916869619f91b09ac71ef95907a

3 years agoMerge branch 'patch-1' of https://github.com/abitrolly/sqlalchemy into abitrolly...
Mike Bayer [Tue, 22 Mar 2022 13:55:53 +0000 (09:55 -0400)] 
Merge branch 'patch-1' of https://github.com/abitrolly/sqlalchemy into abitrolly-patch-1

Change-Id: Ic312eed882e9d6b547e8b4ef0c6f184c2b253547

3 years agouse begin() for settting up first PK
Mike Bayer [Mon, 21 Mar 2022 21:47:34 +0000 (17:47 -0400)] 
use begin() for settting up first PK

Change-Id: I227bbb46fbcbae1f60d3f5bb4dd2b9f41ca3dd0c

3 years agonote that horizontal sharding supports multi schema translates
Mike Bayer [Mon, 21 Mar 2022 21:35:26 +0000 (17:35 -0400)] 
note that horizontal sharding supports multi schema translates

the horizontal sharding API needs some work as it is
still exposing some legacy details, but in any case illustrate
how we can, for the moment, to use multiple schema translate
maps in a single session.

A lot more cleanup is needed in horizontal sharding, see #7837

Change-Id: Ia925e2226ecee9d747a8c4fc1772917f10bc505f
References: #7832
References: #7837

3 years agoadditional updates to stream results note
Mike Bayer [Mon, 21 Mar 2022 20:29:59 +0000 (16:29 -0400)] 
additional updates to stream results note

Change-Id: I9d7ed9f412a2d9384f6c0b50316df79b6f8f481a

3 years agoMerge "test #7820" into main
mike bayer [Mon, 21 Mar 2022 19:57:52 +0000 (19:57 +0000)] 
Merge "test #7820" into main

3 years agoadd note that schema translate not supported per object
Mike Bayer [Mon, 21 Mar 2022 13:07:51 +0000 (09:07 -0400)] 
add note that schema translate not supported per object

Fixes: #7832
Change-Id: I241e4cbd1b5d6df46e49e29e4ab1cac021f2895c

3 years agoMerge "pep 484 for types" into main
mike bayer [Sun, 20 Mar 2022 13:48:17 +0000 (13:48 +0000)] 
Merge "pep 484 for types" into main

3 years agoMerge "Remove duplicate entry in .gitignore" into main
mike bayer [Sun, 20 Mar 2022 13:43:38 +0000 (13:43 +0000)] 
Merge "Remove duplicate entry in .gitignore" into main

3 years agoMerge "catch unexpected errors when accessing clslevel attribute" into main
mike bayer [Sun, 20 Mar 2022 13:37:37 +0000 (13:37 +0000)] 
Merge "catch unexpected errors when accessing clslevel attribute" into main

3 years agoSmall docs fix in 'Relationship Loading Techniques' (#7824)
Andrés Álvarez [Sun, 20 Mar 2022 11:26:25 +0000 (05:26 -0600)] 
Small docs fix in 'Relationship Loading Techniques' (#7824)

3 years agopep 484 for types
Mike Bayer [Thu, 17 Mar 2022 20:18:55 +0000 (16:18 -0400)] 
pep 484 for types

strict types type_api.py, including TypeDecorator,
NativeForEmulated, etc.

Change-Id: Ib2eba26de0981324a83733954cb7044a29bbd7db

3 years agocatch unexpected errors when accessing clslevel attribute
Mike Bayer [Fri, 18 Mar 2022 14:33:40 +0000 (10:33 -0400)] 
catch unexpected errors when accessing clslevel attribute

Improved the error message that's raised for the case where the
:func:`.association_proxy` construct attempts to access a target attribute
at the class level, and this access fails. The particular use case here is
when proxying to a hybrid attribute that does not include a working
class-level implementation.

Fixes: #7827
Change-Id: Ic6ff9df010f49253e664a1e7c7e16d8546006965

3 years agoRemove duplicate entry in .gitignore
Gord Thompson [Thu, 17 Mar 2022 19:38:39 +0000 (13:38 -0600)] 
Remove duplicate entry in .gitignore

Change-Id: I0785c77398d067d06434f387897874aaf137b18d