]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agotry to support mypy 0.990
Mike Bayer [Wed, 9 Nov 2022 14:13:44 +0000 (09:13 -0500)] 
try to support mypy 0.990

mypy introduces a crash we need to work around, also
some new rules.  It also has either a behavioral change
regarding how output is rendered in relationship to
files being within sys.path or not, so work around
that for test_mypy_plugin_py3k.py

References: https://github.com/python/mypy/issues/14027
Change-Id: I689c7fe27dc52abee932de9e0fb23b2a2eba76fa

2 years agotest run w/ oracledb on pypi, disable mariadb-connector
Mike Bayer [Tue, 8 Nov 2022 23:29:13 +0000 (18:29 -0500)] 
test run w/ oracledb on pypi, disable mariadb-connector

mariadb is still failing:

https://jira.mariadb.org/projects/CONPY/issues/CONPY-236

Change-Id: I63a82ce8b33acb7f550d509cd6ed0b8e7a2bd56c

2 years agoadjust update/delete test for non-ordering
Mike Bayer [Tue, 8 Nov 2022 23:28:13 +0000 (18:28 -0500)] 
adjust update/delete test for non-ordering

this test sometimes has different ordering when running under
CI

Change-Id: I6dc3e24c6e23dc00a0ee5ba53e489ad813f12c58

2 years agoblock mariadb-connector 1.1.5
Mike Bayer [Mon, 7 Nov 2022 19:43:39 +0000 (14:43 -0500)] 
block mariadb-connector 1.1.5

package is not installable

See https://jira.mariadb.org/browse/MCOL-5298

Change-Id: I278a1831f379c2c17a1b87dd4c8b3a5b5b585e6d

2 years agodisable sqlite returning on pypy
Mike Bayer [Sat, 5 Nov 2022 14:45:21 +0000 (10:45 -0400)] 
disable sqlite returning on pypy

using latest 3.9-v7.3.9 and returning does not work at all.

Change-Id: I208c3e1ff10949651ffbebc54beea6ede6af1dd3

2 years agogc.collect() in order to ensure GeneratorExit raised on pypy
Mike Bayer [Sat, 5 Nov 2022 14:26:36 +0000 (10:26 -0400)] 
gc.collect() in order to ensure GeneratorExit raised on pypy

Fixes: #8762
Change-Id: Ibf656748ae6a54282ba58e91215e0f7a279b171a

2 years agoVersion 2.0.0b4 placeholder
Mike Bayer [Fri, 4 Nov 2022 21:15:01 +0000 (17:15 -0400)] 
Version 2.0.0b4 placeholder

2 years ago- 2.0.0b3 rel_2_0_0b3
Mike Bayer [Fri, 4 Nov 2022 21:09:03 +0000 (17:09 -0400)] 
- 2.0.0b3

2 years agocherry-pick changelog update for 1.4.44
Mike Bayer [Fri, 4 Nov 2022 21:08:40 +0000 (17:08 -0400)] 
cherry-pick changelog update for 1.4.44

2 years agocherry-pick changelog from 1.4.43
Mike Bayer [Fri, 4 Nov 2022 21:08:39 +0000 (17:08 -0400)] 
cherry-pick changelog from 1.4.43

2 years agotypo
Mike Bayer [Fri, 4 Nov 2022 21:00:29 +0000 (17:00 -0400)] 
typo

Change-Id: I41cb128767c0cba48255cca0904ae1bff1b357ac

2 years agofixes
Mike Bayer [Fri, 4 Nov 2022 20:59:37 +0000 (16:59 -0400)] 
fixes

Change-Id: Id4c3c24bbff0a8bc1f20ff8deb10a098d2cca8b7

2 years agochangelog updates
Mike Bayer [Fri, 4 Nov 2022 20:16:48 +0000 (16:16 -0400)] 
changelog updates

as this release cycle was fairly frenetic, a lot of these
changelogs were very poorly worded (by me).

Change-Id: Idb796cf3e25975fb2f75bacf26f1cb57ef0e4cad

2 years agoMerge "support renamed symbols in annotation scans" into main
mike bayer [Fri, 4 Nov 2022 18:37:56 +0000 (18:37 +0000)] 
Merge "support renamed symbols in annotation scans" into main

2 years agosupport renamed symbols in annotation scans
Mike Bayer [Fri, 4 Nov 2022 15:04:13 +0000 (11:04 -0400)] 
support renamed symbols in annotation scans

Added support in ORM declarative annotations for class names specified for
:func:`_orm.relationship`, as well as the name of the :class:`_orm.Mapped`
symbol itself, to be different names than their direct class name, to
support scenarios such as where :class:`_orm.Mapped` is imported as
``from sqlalchemy.orm import Mapped as M``, or where related class names
are imported with an alternate name in a similar fashion. Additionally, a
target class name given as the lead argument for :func:`_orm.relationship`
will always supersede the name given in the left hand annotation, so that
otherwise un-importable names that also don't match the class name can
still be used in annotations.

Fixes: #8759
Change-Id: I74a00de7e1a45bf62dad50fd385bb75cf343f9f3

2 years agoresolve synonyms in dictionary form of Session.get()
Mike Bayer [Fri, 4 Nov 2022 16:48:43 +0000 (12:48 -0400)] 
resolve synonyms in dictionary form of Session.get()

Improved "dictionary mode" for :meth:`_orm.Session.get` so that synonym
names which refer to primary key attribute names may be indicated in the
named dictionary.

Fixes: #8753
Change-Id: I56112564a5c23b51b26e01c64087cbf4399cd951

2 years agoSupport result.close() for all iterator patterns
Mike Bayer [Tue, 25 Oct 2022 13:10:09 +0000 (09:10 -0400)] 
Support result.close() for all iterator patterns

This change contains new features for 2.0 only as well as some
behaviors that will be backported to 1.4.

For 1.4 and 2.0:

Fixed issue where the underlying DBAPI cursor would not be closed when
using :class:`_orm.Query` with :meth:`_orm.Query.yield_per` and direct
iteration, if a user-defined exception case were raised within the
iteration process, interrupting the iterator. This would lead to the usual
MySQL-related issues with server side cursors out of sync.

For 1.4 only:

A similar scenario can occur when using :term:`2.x` executions with direct
use of :class:`.Result`, in that case the end-user code has access to the
:class:`.Result` itself and should call :meth:`.Result.close` directly.
Version 2.0 will feature context-manager calling patterns to address this
use case.  However within the 1.4 scope, ensured that ``.close()`` methods
are available on all :class:`.Result` implementations including
:class:`.ScalarResult`, :class:`.MappingResult`.

For 2.0 only:

To better support the use case of iterating :class:`.Result` and
:class:`.AsyncResult` objects where user-defined exceptions may interrupt
the iteration, both objects as well as variants such as
:class:`.ScalarResult`, :class:`.MappingResult`,
:class:`.AsyncScalarResult`, :class:`.AsyncMappingResult` now support
context manager usage, where the result will be closed at the end of
iteration.

Corrected various typing issues within the engine and async engine
packages.

Fixes: #8710
Change-Id: I3166328bfd3900957eb33cbf1061d0495c9df670

2 years agoMerge "Improve typings of execution options" into main
mike bayer [Thu, 3 Nov 2022 20:16:05 +0000 (20:16 +0000)] 
Merge "Improve typings of execution options" into main

2 years agoMerge "Implement contains_value(), issubset() and issuperset() on PG Range" into...
mike bayer [Thu, 3 Nov 2022 20:11:58 +0000 (20:11 +0000)] 
Merge "Implement contains_value(), issubset() and issuperset() on PG Range" into main

2 years agoDOC: Fix typo avoiding rendering of legacy marker (#8752)
Patrick Hoefler [Thu, 3 Nov 2022 18:36:35 +0000 (19:36 +0100)] 
DOC: Fix typo avoiding rendering of legacy marker (#8752)

2 years agoImplement contains_value(), issubset() and issuperset() on PG Range
Lele Gaifax [Wed, 2 Nov 2022 12:33:41 +0000 (08:33 -0400)] 
Implement contains_value(), issubset() and issuperset() on PG Range

Added new methods :meth:`_postgresql.Range.contains` and
:meth:`_postgresql.Range.contained_by` to the new :class:`.Range` data
object, which mirror the behavior of the PostgreSQL ``@>`` and ``<@``
operators, as well as the
:meth:`_postgresql.AbstractRange.comparator_factory.contains` and
:meth:`_postgresql.AbstractRange.comparator_factory.contained_by` SQL
operator methods. Pull request courtesy Lele Gaifax.

Fixes: #8706
Closes: #8707
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8707
Pull-request-sha: 3a74a0d93e63032ebee02992977498c717a077ff

Change-Id: Ief81ca5c31448640b26dfbc3defd4dde1d51e366

2 years agoImprove typings of execution options
Federico Caselli [Mon, 17 Oct 2022 20:02:13 +0000 (22:02 +0200)] 
Improve typings of execution options

Fixes: #8605
Change-Id: I4aec83b9f321462427c3f4ac941c3b272255c088

2 years agocorrect typo in async postgresql uri (#8736)
Yomain [Wed, 2 Nov 2022 20:44:30 +0000 (21:44 +0100)] 
correct typo in async postgresql uri (#8736)

2 years agoMerge "use simple decimal query to detect decimal char" into main
mike bayer [Wed, 2 Nov 2022 16:56:59 +0000 (16:56 +0000)] 
Merge "use simple decimal query to detect decimal char" into main

2 years agofix event name
Mike Bayer [Wed, 2 Nov 2022 12:39:39 +0000 (08:39 -0400)] 
fix event name

Change-Id: I26af2326034be07f0ebc91dfbf31d00c40acf585
References: #8717

2 years agouse simple decimal query to detect decimal char
Mike Bayer [Mon, 31 Oct 2022 19:09:34 +0000 (15:09 -0400)] 
use simple decimal query to detect decimal char

Fixed issue where the ``nls_session_parameters`` view queried on first
connect in order to get the default decimal point character may not be
available depending on Oracle connection modes, and would therefore raise
an error.  The approach to detecting decimal char has been simplified to
test a decimal value directly, instead of reading system views, which
works on any backend / driver.

Fixes: #8744
Change-Id: I39825131c13513798863197d0c180dd5a18b32dc

2 years agoevaluate types in terms of the class in which they appear
Mike Bayer [Mon, 31 Oct 2022 13:51:51 +0000 (09:51 -0400)] 
evaluate types in terms of the class in which they appear

Fixed issues within the declarative typing resolver (i.e. which resolves
``ForwardRef`` objects) where types that were declared for columns in one
particular source file would raise ``NameError`` when the ultimate mapped
class were in another source file.  The types are now resolved in terms
of the module for each class in which the types are used.

Fixes: #8742
Change-Id: I236f94484ea79d47392a6201e671eeb89c305fd8

2 years agoMerge "ensure pool.reset event always called for reset" into main
mike bayer [Sun, 30 Oct 2022 21:49:24 +0000 (21:49 +0000)] 
Merge "ensure pool.reset event always called for reset" into main

2 years agoMerge "fix test for same mapper to use "isa"" into main
mike bayer [Sun, 30 Oct 2022 20:08:02 +0000 (20:08 +0000)] 
Merge "fix test for same mapper to use "isa"" into main

2 years agoensure pool.reset event always called for reset
Mike Bayer [Tue, 25 Oct 2022 20:00:50 +0000 (16:00 -0400)] 
ensure pool.reset event always called for reset

Added new parameter :paramref:`.PoolEvents.reset.reset_state` parameter to
the :meth:`.PoolEvents.reset` event, with deprecation logic in place that
will continue to accept event hooks using the previous set of arguments.
This indicates various state information about how the reset is taking
place and is used to allow custom reset schemes to take place with full
context given.

Within this change a fix that's also backported to 1.4 is included which
re-enables the :meth:`.PoolEvents.reset` event to continue to take place
under all circumstances, including when :class:`.Connection` has already
"reset" the connection.

The two changes together allow custom reset schemes to be implemented using
the :meth:`.PoolEvents.reset` event, instead of the
:meth:`.PoolEvents.checkin` event (which continues to function as it always
has).

Change-Id: Ie17c4f55d02beb6f570b9de6b3044baffa7d6df6
Fixes: #8717
2 years agofix test for same mapper to use "isa"
Mike Bayer [Sun, 30 Oct 2022 00:08:25 +0000 (20:08 -0400)] 
fix test for same mapper to use "isa"

Fixed issue in joined eager loading where an assertion fail would occur
with a particular combination of outer/inner joined eager loads in
conjunction with an inherited subclass mapper as the middle target.

Fixes: #8738
Change-Id: I4909e7518302cbb82046e0425abbbdc8eb1c0146

2 years agoadd Mapped to attrs example
Mike Bayer [Sun, 30 Oct 2022 13:05:05 +0000 (09:05 -0400)] 
add Mapped to attrs example

this doesn't work if we dont include this,
or the `__allow_unmapped__` thing, but `Mapped[]` is nicer

Change-Id: Iccdeb865d4e615ea6740720f6656e2558a2b36b8
References: #8740

2 years agoMerge "use only object_id() function for temp tables" into main
mike bayer [Sat, 29 Oct 2022 01:36:19 +0000 (01:36 +0000)] 
Merge "use only object_id() function for temp tables" into main

2 years agoMerge "ensure _ORMJoin transfers parententity from left side" into main
mike bayer [Sat, 29 Oct 2022 01:35:00 +0000 (01:35 +0000)] 
Merge "ensure _ORMJoin transfers parententity from left side" into main

2 years agoupdate rel/fk FAQ entry
Mike Bayer [Fri, 28 Oct 2022 16:20:22 +0000 (12:20 -0400)] 
update rel/fk FAQ entry

this entry still made the assumptions of behavior before
ticket #3061, that accessing a non-initialized scalar attribute
on a pending object would populate the attribute with None.
It also used the word "initialize" when referring to a persistent
object which is a misleading term, it's "loaded", even though
in this example it's "loading" the value of None.

Fix up the language to be more consistent with the #3061 change.

Change-Id: I1abd8f1d2e9c44ebc9a29737ea270b338f104a3e

2 years agoensure _ORMJoin transfers parententity from left side
Mike Bayer [Thu, 27 Oct 2022 02:59:51 +0000 (22:59 -0400)] 
ensure _ORMJoin transfers parententity from left side

Fixed bug involving :class:`.Select` constructs which used a combination of
:meth:`.Select.select_from` with an ORM entity followed by
:meth:`.Select.join` against the entity sent in
:meth:`.Select.select_from`, as well as using plain
:meth:`.Select.join_from`, which when combined with a columns clause that
didn't explicitly include that entity would then cause "automatic WHERE
criteria" features such as the IN expression required for a single-table
inheritance subclass, as well as the criteria set up by the
:func:`_orm.with_loader_criteria` option, to not be rendered for that
entity. The correct entity is now transferred to the :class:`.Join` object
that's generated internally, so that the criteria against the left
side entity is correctly added.

Fixes: #8721
Change-Id: I8266430063e2c72071b7262fdd5ec5079fbcba3e

2 years agorestructure dragon to alleviate ambiguity
Mike Bayer [Fri, 28 Oct 2022 15:40:39 +0000 (11:40 -0400)] 
restructure dragon to alleviate ambiguity

dragons are eye catching so let's make sure the dragon is
very specific about what it's referring towards

Change-Id: I2faaef2352c7984d4c1c7d599849a9179a1e7776
References: #8732

2 years agoMerge "apply basic escaping to anon_labels unconditionally" into main
mike bayer [Fri, 28 Oct 2022 13:59:05 +0000 (13:59 +0000)] 
Merge "apply basic escaping to anon_labels unconditionally" into main

2 years agoMerge "ensure inherited mapper attrs not interpreted as plain dataclass fields" into...
mike bayer [Fri, 28 Oct 2022 13:57:40 +0000 (13:57 +0000)] 
Merge "ensure inherited mapper attrs not interpreted as plain dataclass fields" into main

2 years agouse only object_id() function for temp tables
Mike Barry [Wed, 26 Oct 2022 17:40:32 +0000 (13:40 -0400)] 
use only object_id() function for temp tables

Fixed issue with :meth:`.Inspector.has_table` when used against a temporary
table for the SQL Server dialect would fail an invalid object name error on
some Azure variants, due to an unnecessary information schema query that is
not supported on those server versions. Pull request courtesy Mike Barry.

the patch also fills out test support for has_table()
against temp tables, temp views, adding to the has_table() support just
added for views in #8700.

Fixes: #8714
Closes: #8716
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8716
Pull-request-sha: e2ac7a52e2b09a349a703ba1e1a2911f4d3c0912

Change-Id: Ia73e4e9e977a2d6b7e100abd2f81a8c8777dc9bb

2 years agoopen some compound tests for mysql 8.0.31
Mike Bayer [Fri, 28 Oct 2022 05:49:48 +0000 (01:49 -0400)] 
open some compound tests for mysql 8.0.31

Not sure of exact version but as we have done a major
rebuild of CI, newer mysql 8.0 is passing on these.

Change-Id: Ibcfe0ce519ab6a2941ca514b4254944769b60df4

2 years agomssql doc updates
Mike Bayer [Fri, 28 Oct 2022 05:49:03 +0000 (01:49 -0400)] 
mssql doc updates

clarify some URL things

Change-Id: Ic162834052f06fd3a6c010ce5d091903fdc65cd8

2 years agoBump pypa/cibuildwheel from 2.11.1 to 2.11.2 (#8729)
dependabot[bot] [Thu, 27 Oct 2022 17:46:02 +0000 (19:46 +0200)] 
Bump pypa/cibuildwheel from 2.11.1 to 2.11.2 (#8729)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.11.1 to 2.11.2.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.11.1...v2.11.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoapply basic escaping to anon_labels unconditionally
Mike Bayer [Thu, 27 Oct 2022 13:28:02 +0000 (09:28 -0400)] 
apply basic escaping to anon_labels unconditionally

Fixed issue which prevented the :func:`_sql.literal_column` construct from
working properly within the context of a :class:`.Select` construct as well
as other potential places where "anonymized labels" might be generated, if
the literal expression contained characters which could interfere with
format strings, such as open parenthesis, due to an implementation detail
of the "anonymous label" structure.

Fixes: #8724
Change-Id: I3089124fbd055a011c8a245964258503b717d941

2 years agoensure inherited mapper attrs not interpreted as plain dataclass fields
Mike Bayer [Wed, 26 Oct 2022 17:27:21 +0000 (13:27 -0400)] 
ensure inherited mapper attrs not interpreted as plain dataclass fields

Fixed issue in new dataclass mapping feature where a column declared on the
decalrative base / abstract base / mixin would leak into the constructor
for an inheriting subclass under some circumstances.

Fixes: #8718
Change-Id: Ic519acf239e2f80541516f10995991cbbbed00bd

2 years agoMerge "reconcile Mapper properties ordering against mapped Table" into main
mike bayer [Tue, 25 Oct 2022 20:55:11 +0000 (20:55 +0000)] 
Merge "reconcile Mapper properties ordering against mapped Table" into main

2 years agoreconcile Mapper properties ordering against mapped Table
Mike Bayer [Mon, 24 Oct 2022 15:29:36 +0000 (11:29 -0400)] 
reconcile Mapper properties ordering against mapped Table

Changed a fundamental configuration behavior of :class:`.Mapper`, where
:class:`_schema.Column` objects that are explicitly present in the
:paramref:`_orm.Mapper.properties` dictionary, either directly or enclosed
within a mapper property object, will now be mapped within the order of how
they appear within the mapped :class:`.Table` (or other selectable) itself
(assuming they are in fact part of that table's list of columns), thereby
maintaining the same order of columns in the mapped selectable as is
instrumented on the mapped class, as well as what renders in an ORM SELECT
statement for that mapper. Previously (where "previously" means since
version 0.0.1), :class:`.Column` objects in the
:paramref:`_orm.Mapper.properties` dictionary would always be mapped first,
ahead of when the other columns in the mapped :class:`.Table` would be
mapped, causing a discrepancy in the order in which the mapper would
assign attributes to the mapped class as well as the order in which they
would render in statements.

The change most prominently takes place in the way that Declarative
assigns declared columns to the :class:`.Mapper`, specifically how
:class:`.Column` (or :func:`_orm.mapped_column`) objects are handled
when they have a DDL name that is explicitly different from the mapped
attribute name, as well as when constructs such as :func:`_orm.deferred`
etc. are used.   The new behavior will see the column ordering within
the mapped :class:`.Table` being the same order in which the attributes
are mapped onto the class, assigned within the :class:`.Mapper` itself,
and rendered in ORM statements such as SELECT statements, independent
of how the :class:`_schema.Column` was configured against the
:class:`.Mapper`.

Fixes: #8705
Change-Id: I95cc05061a97fe6b1654bab70e2f6da30f8f3bd3

2 years agoraise for non-Load opt passed to options()
Mike Bayer [Tue, 25 Oct 2022 14:22:14 +0000 (10:22 -0400)] 
raise for non-Load opt passed to options()

Fixed the exception that's raised when the
:func:`_orm.with_loader_criteria` option is attempted to be used within a
specific loader path, like in loader.options().
:func:`_orm.with_loader_criteria` is only intended to be used at the top
level.

Fixes: #8711
Change-Id: Iaa7b13956b808761e618a6be6406e5c82df1c65c

2 years agoMerge "add Oracle-specific parameter escapes for expanding params" into main
mike bayer [Tue, 25 Oct 2022 02:53:12 +0000 (02:53 +0000)] 
Merge "add Oracle-specific parameter escapes for expanding params" into main

2 years agoadd Oracle-specific parameter escapes for expanding params
Mike Bayer [Mon, 24 Oct 2022 23:24:11 +0000 (19:24 -0400)] 
add Oracle-specific parameter escapes for expanding params

Fixed issue where bound parameter names, including those automatically
derived from similarly-named database columns, which contained characters
that normally require quoting with Oracle would not be escaped when using
"expanding parameters" with the Oracle dialect, causing execution errors.
The usual "quoting" for bound parameters used by the Oracle dialect is not
used with the "expanding parameters" architecture, so escaping for a large
range of characters is used instead, now using a list of characters/escapes
that are specific to Oracle.

Fixes: #8708
Change-Id: I90c24e48534e1b3a4c222b3022da58159784d91a

2 years agoMerge "skip ad-hoc properties within subclass_load_via_in" into main
mike bayer [Mon, 24 Oct 2022 16:18:07 +0000 (16:18 +0000)] 
Merge "skip ad-hoc properties within subclass_load_via_in" into main

2 years agoMerge "Add pep 584 to python immutabledict fallback" into main
mike bayer [Sun, 23 Oct 2022 23:40:42 +0000 (23:40 +0000)] 
Merge "Add pep 584 to python immutabledict fallback" into main

2 years agoMerge "DeclarativeBase ``__table__`` annotation is not optional" into main
mike bayer [Sun, 23 Oct 2022 23:37:53 +0000 (23:37 +0000)] 
Merge "DeclarativeBase ``__table__`` annotation is not optional" into main

2 years agoskip ad-hoc properties within subclass_load_via_in
Mike Bayer [Sun, 23 Oct 2022 23:24:54 +0000 (19:24 -0400)] 
skip ad-hoc properties within subclass_load_via_in

Fixed issue where "selectin_polymorphic" loading for inheritance mappers
would not function correctly if the :param:`_orm.Mapper.polymorphic_on`
parameter referred to a SQL expression that was not directly mapped on the
class.

Fixes: #8704
Change-Id: I1b6be2650895fd18d2c804f6ba96de966d11041a

2 years agotest support for has_table()->view; backport to 1.4
Mike Bayer [Sun, 23 Oct 2022 14:34:33 +0000 (10:34 -0400)] 
test support for has_table()->view; backport to 1.4

For 1.4 only; in 2.0 this just refines the test suite a bit.

Fixed regression which occurred throughout the 1.4 series where the
:meth:`.Inspector.has_table` method, which historically reported on views
as well, stopped working for SQL Server. The issue is not present in the
2.0 series which uses a different reflection architecture. Test support is
added to ensure ``has_table()`` remains working per spec re: views.

Fixes: #8700
Change-Id: I119a91ec07911edb08cf0799234827fec9ea1195

2 years agoDeclarativeBase ``__table__`` annotation is not optional
Federico Caselli [Sat, 22 Oct 2022 07:57:18 +0000 (09:57 +0200)] 
DeclarativeBase ``__table__`` annotation is not optional

Change-Id: I92bfc0cf58fa2e6f9d7e8055f1a337ec806c1410

2 years agoAdd pep 584 to python immutabledict fallback
Federico Caselli [Fri, 21 Oct 2022 19:11:23 +0000 (21:11 +0200)] 
Add pep 584 to python immutabledict fallback

Fixes: #8695
Change-Id: Ie0412c3a7b2b1ba5bd5112f204318ff763cbb8f4

2 years agoMerge "Only convert Range for sqlalchemy Range object" into main
mike bayer [Fri, 21 Oct 2022 17:29:23 +0000 (17:29 +0000)] 
Merge "Only convert Range for sqlalchemy Range object" into main

2 years agoMerge "allow legacy forms with __allow_unmapped__" into main
mike bayer [Fri, 21 Oct 2022 16:41:02 +0000 (16:41 +0000)] 
Merge "allow legacy forms with __allow_unmapped__" into main

2 years agoOnly convert Range for sqlalchemy Range object
Mike Bayer [Fri, 21 Oct 2022 16:37:04 +0000 (12:37 -0400)] 
Only convert Range for sqlalchemy Range object

Refined the new approach to range objects described at :ref:`change_7156`
to accommodate driver-specific range and multirange objects, to better
accommodate both legacy code as well as when passing results from raw SQL
result sets back into new range or multirange expressions.

Fixes: #8690
Change-Id: I7e62c47067f695c6380ad0fe2fe19deaf33594d1

2 years agoallow legacy forms with __allow_unmapped__
Mike Bayer [Fri, 21 Oct 2022 04:11:10 +0000 (00:11 -0400)] 
allow legacy forms with __allow_unmapped__

Improved support for legacy 1.4 mappings that use annotations which don't
include ``Mapped[]``, by ensuring the ``__allow_unmapped__`` attribute can
be used to allow such legacy annotations to pass through Annotated
Declarative without raising an error and without being interpreted in an
ORM runtime context. Additionally improved the error message generated when
this condition is detected, and added more documentation for how this
situation should be handled. Unfortunately the 1.4 WARN_SQLALCHEMY_20
migration warning cannot detect this particular configurational issue at
runtime with its current architecture.

Fixes: #8692
Change-Id: I5c642bcc1ebb7816f9470ec9bb0951550b6d55f1

2 years agofix missing pool __init__ documentation
Mike Bayer [Fri, 21 Oct 2022 13:26:26 +0000 (09:26 -0400)] 
fix missing pool __init__ documentation

Change-Id: Ic3e7fb3cc4995372646822e40d914b83a7fa78c8

2 years agoVersion 2.0.0b3 placeholder
Mike Bayer [Thu, 20 Oct 2022 17:47:22 +0000 (13:47 -0400)] 
Version 2.0.0b3 placeholder

2 years ago- 2.0.0b2 rel_2_0_0b2
Mike Bayer [Thu, 20 Oct 2022 17:40:54 +0000 (13:40 -0400)] 
- 2.0.0b2

2 years agodoc classification changes
Mike Bayer [Thu, 20 Oct 2022 17:39:21 +0000 (13:39 -0400)] 
doc classification changes

Change-Id: If7e16f4c9578fec70168db701d1860bf5e4d6d42

2 years agodoc link fixes
Mike Bayer [Thu, 20 Oct 2022 17:08:52 +0000 (13:08 -0400)] 
doc link fixes

Change-Id: I7f5f6b8070c01066a64f23542f644ad67db70d38

2 years agoMerge "collect annotation earlier for mapped_column present" into main
mike bayer [Thu, 20 Oct 2022 17:05:03 +0000 (17:05 +0000)] 
Merge "collect annotation earlier for mapped_column present" into main

2 years agomove API docs downwards
Mike Bayer [Thu, 20 Oct 2022 16:28:29 +0000 (12:28 -0400)] 
move API docs downwards

Sphinx 5.3 (compared to 5.1.1) is now putting all the autodoc
names into the TOC.   So we have to start being more careful
to make sure API docs are well below narrative docs, because
this new style is a wall of text.   i dont yet see any options
to turn it off, but it does seem like a good improvement, just makes
doc organization a more difficult endeavor.

Change-Id: I49428076fef9b96ef1544621de9a9dfca1699dab

2 years agocollect annotation earlier for mapped_column present
Mike Bayer [Thu, 20 Oct 2022 16:05:33 +0000 (12:05 -0400)] 
collect annotation earlier for mapped_column present

Fixed issue with new dataclass mapping feature where arguments passed to
the dataclasses API could sometimes be mis-ordered when dealing with mixins
that override :func:`_orm.mapped_column` declarations, leading to
initializer problems.

the change made here is specific to the test case given which regards
mapped_column() most specifically.   cases that involve relationship()
etc. are not tested here, however mapped_column() is the only attribute
that's implicit without an instance given on the right side, and is also
most common for mixins.   not clear if there are more issues in this
area, however it appears that we need only adjust the order in which we
accommodate grabbing the annotations in order to affect how dataclasses
sees the class; that is, we have control over ``__annotations__`` here
so dont have to worry about ``cls.__dict__``.

Fixes: #8688
Change-Id: I808c86f23d73aa47cd910ae01c3e07093d469fdc

2 years agoMerge "Improve typing of DeclarativeBase" into main
mike bayer [Thu, 20 Oct 2022 13:20:34 +0000 (13:20 +0000)] 
Merge "Improve typing of DeclarativeBase" into main

2 years agoImprove typing of DeclarativeBase
Federico Caselli [Tue, 18 Oct 2022 19:08:48 +0000 (21:08 +0200)] 
Improve typing of DeclarativeBase

Also allow mapped columns inside indexes, unique cosntraints, primary key constriant

Fixes: #8645
Change-Id: If37ab85ead0fbd1125cd6329c2f01a031777b081

2 years agomore many-to-one typing
Mike Bayer [Wed, 19 Oct 2022 13:41:44 +0000 (09:41 -0400)] 
more many-to-one typing

since we are typing centric, note this configuration
as we have just supported in #8668.

Note also I am just taking "backref" out of the basic
version of the docs here totally, this doc is already
a lot to read / take in without making it even more
confusing; backref still has an entirely dedicated
docs page which can have all the additional behaviors
of backref() described.

Additionally, get other "optional" forms to work including
``cls | None`` and ``Union[cls, None]``.

Fixes: #8668
Change-Id: I2b026f496a1710ddebfb4aa6cf8459b4892cbc54

2 years agoMerge "de-optionalize union types to support Optional for m2o" into main
mike bayer [Wed, 19 Oct 2022 13:33:55 +0000 (13:33 +0000)] 
Merge "de-optionalize union types to support Optional for m2o" into main

2 years agoMerge "call super().__init_subclass__(); support GenericAlias" into main
mike bayer [Wed, 19 Oct 2022 13:33:34 +0000 (13:33 +0000)] 
Merge "call super().__init_subclass__(); support GenericAlias" into main

2 years agorename tables to _table for basic relationships
Mike Bayer [Wed, 19 Oct 2022 13:17:03 +0000 (09:17 -0400)] 
rename tables to _table for basic relationships

the names "parent" / "child" are confusing for new users
in that they are used for table names as well as
"back_populates='parent'", use a disambiguated name.

In this change, there's now overlap between the
variable named "association_table" and the table name
"association_table".  not sure of a better naming system.

Change-Id: Ic036c8072caf6e9e5fbd1178986353c00b91f43d
References: https://github.com/sqlalchemy/sqlalchemy/discussions/8675#discussioncomment-3915204

2 years agode-optionalize union types to support Optional for m2o
Mike Bayer [Wed, 19 Oct 2022 01:01:05 +0000 (21:01 -0400)] 
de-optionalize union types to support Optional for m2o

Fixed bug in new ORM typed declarative mappings where we did not include
the ability to use ``Optional[]`` in the type annotation for a many-to-one
relationship, even though this is common.

Fixes: #8668
Change-Id: Idaf0846e49cc12095394b99ad6fe678735cf9242

2 years agocall super().__init_subclass__(); support GenericAlias
Mike Bayer [Tue, 18 Oct 2022 17:25:06 +0000 (13:25 -0400)] 
call super().__init_subclass__(); support GenericAlias

Improved the :class:`.DeclarativeBase` class so that when combined with
other mixins like :class:`.MappedAsDataclass`, the order of the classes may
be in either order.

Added support for mapped classes that are also ``Generic`` subclasses,
to be specified as a ``GenericAlias`` object (e.g. ``MyClass[str]``)
within statements and calls to :func:`_sa.inspect`.

Fixes: #8665
Change-Id: I03063a28b0438a44b9e028fd9d45e8ce08bd18c4

2 years agoMerge "further qualify pyodbc setinputsizes types for long stirngs" into main
mike bayer [Wed, 19 Oct 2022 00:18:17 +0000 (00:18 +0000)] 
Merge "further qualify pyodbc setinputsizes types for long stirngs" into main

2 years agofurther qualify pyodbc setinputsizes types for long stirngs
Mike Bayer [Tue, 18 Oct 2022 13:44:37 +0000 (09:44 -0400)] 
further qualify pyodbc setinputsizes types for long stirngs

Fixed regression caused by SQL Server pyodbc change :ticket:`8177` where we
now use ``setinputsizes()`` by default; for VARCHAR, this fails if the
character size is greater than 4000 (or 2000, depending on data) characters
as the incoming datatype is NVARCHAR, which has a limit of 4000 characters,
despite the fact that VARCHAR can handle unlimited characters. Additional
pyodbc-specific typing information is now passed to ``setinputsizes()``
when the datatype's size is > 2000 characters. The change is also applied
to the :class:`.JSON` type which was also impacted by this issue for large
JSON serializations.

Fixes: #8661
Change-Id: I07fa873e95dbd2c94f3d286e93e8b3229c3a9807

2 years agoImprove proxy methods with the changes from the abandoned
Federico Caselli [Tue, 18 Oct 2022 17:57:19 +0000 (19:57 +0200)] 
Improve proxy methods with the changes from the abandoned
I5c7f172e5224fa08d0675160ac919d0b045a26eb

Change-Id: Ieb7971297f959fd635a4627bd93154e28ef0ef2b

2 years agoRevert automatic set of sequence start to 1
Federico Caselli [Sat, 24 Sep 2022 13:50:26 +0000 (15:50 +0200)] 
Revert automatic set of sequence start to 1

The :class:`.Sequence` construct restores itself to the DDL behavior it
had prior to the 1.4 series, where creating a :class:`.Sequence` with
no additional arguments will emit a simple ``CREATE SEQUENCE`` instruction
**without** any additional parameters for "start value".   For most backends,
this is how things worked previously in any case; **however**, for
MS SQL Server, the default value on this database is
``-2**63``; to prevent this generally impractical default
from taking effect on SQL Server, the :paramref:`.Sequence.start` parameter
should be provided.   As usage of :class:`.Sequence` is unusual
for SQL Server which for many years has standardized on ``IDENTITY``,
it is hoped that this change has minimal impact.

Fixes: #7211
Change-Id: I1207ea10c8cb1528a1519a0fb3581d9621c27b31

2 years agoupdate SEQUENCE docs ahead of default change
Mike Bayer [Mon, 17 Oct 2022 19:09:01 +0000 (15:09 -0400)] 
update SEQUENCE docs ahead of default change

for backport to 1.4 as well, remove references to
Firebird, and also revert "associate Sequence with MetaData"
step as this is not needed usually, just note that schema
is not shared.  encourage users to use IDENTITY instead.

Change-Id: I5d25357042127c9cd1274c9de7abb44a525b0195

2 years agosimplify unmapped col eval fallback
Mike Bayer [Mon, 17 Oct 2022 15:53:07 +0000 (11:53 -0400)] 
simplify unmapped col eval fallback

Removed the warning that emits when using ORM-enabled update/delete
regarding evaluation of columns by name, first added in :ticket:`4073`;
this warning actually covers up a scenario that otherwise could populate
the wrong Python value for an ORM mapped attribute depending on what the
actual column is, so this deprecated case is removed. In 2.0, ORM enabled
update/delete uses "auto" for "synchronize_session", which should do the
right thing automatically for any given UPDATE expression.

Fixes: #8656
Change-Id: Idb8b4a86d3caed89f69cde1607886face103cf6a

2 years agofix imports in asyncio example
Mike Bayer [Mon, 17 Oct 2022 13:00:20 +0000 (09:00 -0400)] 
fix imports in asyncio example

Change-Id: I1f746f9dafac35dc9c9def8ee16a6ee7eacdfcfe

2 years agoMerge "repair type qualify in _ServerDefaultType; other pyright tweaks" into main
mike bayer [Mon, 17 Oct 2022 12:59:05 +0000 (12:59 +0000)] 
Merge "repair type qualify in _ServerDefaultType; other pyright tweaks" into main

2 years agorepair type qualify in _ServerDefaultType; other pyright tweaks
Mike Bayer [Sun, 16 Oct 2022 22:30:44 +0000 (18:30 -0400)] 
repair type qualify in _ServerDefaultType; other pyright tweaks

as we haven't done full pylance / pyright strict typing internally,
some of the things pyright reports on specifically will leak
out into user code, such as this mapped_column() issue.
So we will have to look more closely at pyright strict
mode going forward for the release.

Fixed typing issue where pylance strict mode would report "partially
unknown" datatype for the :func:`_orm.mapped_column` construct.

Also repaired a trailing comma and pyright complaining about overloads
for orm.composite.

Fixes: #8644
Change-Id: Ia48dc5dbd56bbceeacee4f0daf9810bfdea3bee3

2 years agocherry-pick changelog update for 1.4.43
Mike Bayer [Sun, 16 Oct 2022 14:25:36 +0000 (10:25 -0400)] 
cherry-pick changelog update for 1.4.43

2 years agocherry-pick changelog from 1.4.42
Mike Bayer [Sun, 16 Oct 2022 14:25:36 +0000 (10:25 -0400)] 
cherry-pick changelog from 1.4.42

2 years agoadd python 3.11 to supported versions
Mike Bayer [Sun, 16 Oct 2022 14:09:20 +0000 (10:09 -0400)] 
add python 3.11 to supported versions

Change-Id: Ibf699297b12c1c72c570db380282e97adfdef2b9

2 years agoaccommodate arbitrary embedded params in insertmanyvalues
Mike Bayer [Sat, 15 Oct 2022 19:20:21 +0000 (15:20 -0400)] 
accommodate arbitrary embedded params in insertmanyvalues

Fixed bug in new "insertmanyvalues" feature where INSERT that included a
subquery with :func:`_sql.bindparam` inside of it would fail to render
correctly in "insertmanyvalues" format. This affected psycopg2 most
directly as "insertmanyvalues" is used unconditionally with this driver.

Fixes: #8639
Change-Id: I67903fa86afe208899d4f23f940e0727d1be2ce3

2 years agodisable isort in pyproject.toml
Mike Bayer [Sat, 15 Oct 2022 15:12:25 +0000 (11:12 -0400)] 
disable isort in pyproject.toml

disable isort, for IDEs that just default isort to be turned on, e.g. vscode.
we use flake8-import-order for import sorting, using zimports to actually
reformat code.  isort is nicer in many ways but doesn't have our
"import *" fixer and also is not 100% compatible with flake8-import-order.

Change-Id: I8e53d475cdc1d6178e2c9276d2b21d47be207ede

2 years agofix instances of objects as instances of classes (#8627)
Muhammad Abdur Rakib [Fri, 14 Oct 2022 17:53:49 +0000 (23:53 +0600)] 
fix instances of objects as instances of classes (#8627)

document mentions `creating instances of "User" and "Address" objects` which is a mistake as we create instances or objects from classes.

2 years agoBump pypa/cibuildwheel from 2.10.2 to 2.11.1 (#8630)
dependabot[bot] [Fri, 14 Oct 2022 17:47:26 +0000 (19:47 +0200)] 
Bump pypa/cibuildwheel from 2.10.2 to 2.11.1 (#8630)

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.10.2 to 2.11.1.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](https://github.com/pypa/cibuildwheel/compare/v2.10.2...v2.11.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agocorrect python compat statement
Mike Bayer [Fri, 14 Oct 2022 15:33:54 +0000 (11:33 -0400)] 
correct python compat statement

2.0 uses 3.7 at a minimum, update verbiage here.

Change-Id: I076e205bbfc9b502f1ac382f6292c290c3fc8c1b

2 years agonarrow formatting in table, turn format off
Mike Bayer [Fri, 14 Oct 2022 13:17:09 +0000 (09:17 -0400)] 
narrow formatting in table, turn format off

Change-Id: I0824495e0582657ffb63eaa2466021f56005c81c
References: https://github.com/sqlalchemy/sqlalchemy/discussions/8157#discussioncomment-3878806

2 years agofix declarative styles examples re: imports
Mike Bayer [Fri, 14 Oct 2022 12:41:03 +0000 (08:41 -0400)] 
fix declarative styles examples re: imports

many missing imports and mis-imports, also use
list[] for typing.

Change-Id: Idd9140a89eb421c4b80503639a582b96ba66c601
References: #8634

2 years agofix comment
Mike Bayer [Thu, 13 Oct 2022 15:59:02 +0000 (11:59 -0400)] 
fix comment

Change-Id: I9aaaf1df05a4f54fa0907155160022815280d12e

2 years agoVersion 2.0.0b2 placeholder
Mike Bayer [Thu, 13 Oct 2022 15:32:52 +0000 (11:32 -0400)] 
Version 2.0.0b2 placeholder

2 years ago- 2.0.0b1 rel_2_0_0b1
Mike Bayer [Thu, 13 Oct 2022 15:25:31 +0000 (11:25 -0400)] 
- 2.0.0b1

2 years agofurther 2.0 modernizations
Mike Bayer [Thu, 13 Oct 2022 14:13:01 +0000 (10:13 -0400)] 
further 2.0 modernizations

biggest change here is the old tutorials were removed from the
TOC and some additional links to them have been corrected.

Change-Id: I79b878a946422eac24ed2449b440fc5d556576c4