]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agoBump pypa/cibuildwheel from 2.11.2 to 2.12.0 9107/head
dependabot[bot] [Tue, 17 Jan 2023 15:11:23 +0000 (15:11 +0000)] 
Bump pypa/cibuildwheel from 2.11.2 to 2.12.0

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.11.2 to 2.12.0.
- [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.2...v2.12.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoMerge "dont assume copy_with() on builtins list, dict, etc; improve error msg." into...
mike bayer [Tue, 17 Jan 2023 01:18:47 +0000 (01:18 +0000)] 
Merge "dont assume copy_with() on builtins list, dict, etc; improve error msg." into main

2 years agofix doc warnings
Mike Bayer [Mon, 16 Jan 2023 21:30:10 +0000 (16:30 -0500)] 
fix doc warnings

Change-Id: I38e465ef1902584c3242bb06ed5ed18a8c018285

2 years agoapply changelog note for change of column loader options
Mike Bayer [Mon, 16 Jan 2023 21:02:07 +0000 (16:02 -0500)] 
apply changelog note for change of column loader options

Change-Id: Ib9a69e20420e1fda755f4533c5f90bc08ba11b48
References: #8879
References: #9101

2 years agodont assume copy_with() on builtins list, dict, etc; improve error msg.
Mike Bayer [Mon, 16 Jan 2023 15:31:39 +0000 (10:31 -0500)] 
dont assume copy_with() on builtins list, dict, etc; improve error msg.

Fixed issue where using an ``Annotated`` type in the
``type_annotation_map`` which itself contained a plain container type (e.g.
``list``, ``dict``) generic type as the target type would produce an
internal error where the ORM were trying to interpret the ``Annotated``
instance.

Added an error message when a :func:`_orm.relationship` is mapped against
an abstract container type, such as ``Mapped[Sequence[B]]``, without
providing the :paramref:`_orm.relationship.container_class` parameter which
is necessary when the type is abstract. Previously the the abstract
container would attempt to be instantiated and fail.

Fixes: #9099
Fixes: #9100
Change-Id: I18aa6abd5451c5ac75a9caed8441ff0cd8f44589

2 years agosuper-fine pass through the metadata tutorial
Mike Bayer [Sun, 15 Jan 2023 18:11:38 +0000 (13:11 -0500)] 
super-fine pass through the metadata tutorial

try to keep the wordiness down here, using sidebars
and topics for non-essential information.   Sphinx seems
to read out attrs from under TYPE_CHECKING sections now
so link out the attrs in DeclarativeBase w/ docstrings,
not sure why we didn't think of this earlier.  looks great

Change-Id: Ib2e07e3606185998561c2d77b2564fd3eddb4d75

2 years agofix orm-header for standalone
Mike Bayer [Sun, 15 Jan 2023 16:28:22 +0000 (11:28 -0500)] 
fix orm-header for standalone

Change-Id: I20e7f8ad5800c2ce5cdc9645c4dbe66f53b8cdf8

2 years agoapply pep-612 to hybrid_method; accept SQLCoreOperations
Mike Bayer [Sun, 15 Jan 2023 03:24:36 +0000 (22:24 -0500)] 
apply pep-612 to hybrid_method; accept SQLCoreOperations

Fixes to the annotations within the ``sqlalchemy.ext.hybrid`` extension for
more effective typing of user-defined methods. The typing now uses
:pep:`612` features, now supported by recent versions of Mypy, to maintain
argument signatures for :class:`.hybrid_method`. Return values for hybrid
methods are accepted as SQL expressions in contexts such as
:meth:`_sql.Select.where` while still supporting SQL methods.

Fixes: #9096
Change-Id: Id4e3a38ec50e415220dfc5f022281b11bb262469

2 years agoimplement polymorphic_abstract=True feature
Mike Bayer [Fri, 13 Jan 2023 22:24:14 +0000 (17:24 -0500)] 
implement polymorphic_abstract=True feature

Added a new parameter to :class:`_orm.Mapper` called
:paramref:`_orm.Mapper.polymorphic_abstract`. The purpose of this directive
is so that the ORM will not consider the class to be instantiated or loaded
directly, only subclasses. The actual effect is that the
:class:`_orm.Mapper` will prevent direct instantiation of instances
of the class and will expect that the class does not have a distinct
polymorphic identity configured.

In practice, the class that is mapped with
:paramref:`_orm.Mapper.polymorphic_abstract` can be used as the target of a
:func:`_orm.relationship` as well as be used in queries; subclasses must of
course include polymorphic identities in their mappings.

The new parameter is automatically applied to classes that subclass
the :class:`.AbstractConcreteBase` class, as this class is not intended
to be instantiated.

Additionally, updated some areas of the single table inheritance
documentation to include mapped_column(nullable=False) for all
subclass-only columns; the mappings as given didn't work as the
columns were no longer nullable using Annotated Declarative Table
style.

Fixes: #9060
Change-Id: Ief0278e3945a33a6ff38ac14d39c38ce24910d7f

2 years agofix typo
Mike Bayer [Fri, 13 Jan 2023 19:31:28 +0000 (14:31 -0500)] 
fix typo

Change-Id: I273459175a3c55290b1f6c28f656ed9c4db17ccf

2 years agoMerge "Type annotations for sqlalchemy.sql.selectable" into main
mike bayer [Fri, 13 Jan 2023 19:28:33 +0000 (19:28 +0000)] 
Merge "Type annotations for sqlalchemy.sql.selectable" into main

2 years agoType annotations for sqlalchemy.sql.selectable
Dzmitar [Thu, 12 Jan 2023 15:47:24 +0000 (10:47 -0500)] 
Type annotations for sqlalchemy.sql.selectable

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #9028
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9028
Pull-request-sha: e2f8ddeac0b08feaad917285e988acf1e9465a26

Change-Id: I5caad31bfeeed2d224657a55f067ba1d86b8733f

2 years agoMake the custom type map more discoverable
Federico Caselli [Mon, 9 Jan 2023 20:45:11 +0000 (21:45 +0100)] 
Make the custom type map more discoverable

Change-Id: Id6cdaddad83aa93508e256e54010a6c53218b717

2 years agoMerge "Remove old file and missing doc section" into main
mike bayer [Fri, 13 Jan 2023 14:41:38 +0000 (14:41 +0000)] 
Merge "Remove old file and missing doc section" into main

2 years agoRemove old file and missing doc section
Federico Caselli [Thu, 12 Jan 2023 22:06:54 +0000 (23:06 +0100)] 
Remove old file and missing doc section

Change-Id: Ic6dda7f32a7561a0c0a92b8a7c08e44cb174eec1

2 years agoFixes related to improved sql formatting
Federico Caselli [Thu, 12 Jan 2023 22:03:03 +0000 (23:03 +0100)] 
Fixes related to improved sql formatting

Follow up of I07b72e6620bb64e329d6b641afa27631e91c4f16

Change-Id: I1f61974bf9cdc3da5317e546d4f9b649c2029e4d

2 years agoMerge "add with_loader_criteria() test for #8064 / #9091" into main
mike bayer [Thu, 12 Jan 2023 18:55:04 +0000 (18:55 +0000)] 
Merge "add with_loader_criteria() test for #8064 / #9091" into main

2 years agoMerge "replace @decorated_property decorator" into main
mike bayer [Thu, 12 Jan 2023 18:52:38 +0000 (18:52 +0000)] 
Merge "replace @decorated_property decorator" into main

2 years agoMerge "Support local timespamp support on Oracle" into main
mike bayer [Thu, 12 Jan 2023 17:43:52 +0000 (17:43 +0000)] 
Merge "Support local timespamp support on Oracle" into main

2 years agoreplace @decorated_property decorator
Mike Bayer [Thu, 12 Jan 2023 17:33:09 +0000 (12:33 -0500)] 
replace @decorated_property decorator

This decorator is no longer necessary as of Mypy
0.981 [1].

In current mypy versions, we require direct use of
`@property` for return types of these methods to be
recognized

[1] https://github.com/python/mypy/issues/1362

Change-Id: Ibc36083dec854c5f9140a9b621e9bf9d5bb4fb61

2 years agoMerge "Improve sql formatting" into main
mike bayer [Thu, 12 Jan 2023 16:55:11 +0000 (16:55 +0000)] 
Merge "Improve sql formatting" into main

2 years agoadd with_loader_criteria() test for #8064 / #9091
Mike Bayer [Thu, 12 Jan 2023 16:25:39 +0000 (11:25 -0500)] 
add with_loader_criteria() test for #8064 / #9091

test related to #8064, added after discussion #9091 which
requested this behavior for with_loader_criteria() where it was
found to be working as of this issue, just not tested

Change-Id: I703f25af3708e49380b6004badd3a8ffb783ef70
References: #8064
References: #9091

2 years agoSupport local timespamp support on Oracle
Federico Caselli [Wed, 11 Jan 2023 19:44:07 +0000 (20:44 +0100)] 
Support local timespamp support on Oracle

Added support for the Oracle SQL type ``TIMESTAMP WITH LOCAL TIME ZONE``,
using a newly added Oracle-specific :class:`_oracle.TIMESTAMP` datatype.

Fixes: #9086
Change-Id: Ib14119503a8aaf20e1aa4e36be80ccca37383e90

2 years agoMove docs in mysql dbapi
Federico Caselli [Wed, 11 Jan 2023 19:33:16 +0000 (20:33 +0100)] 
Move docs in mysql dbapi

Fixes: #9084
Change-Id: I5e174c318a20b7fcb5ea7c771293c5102e761ed7

2 years agoImprove sql formatting
Federico Caselli [Tue, 10 Jan 2023 20:39:44 +0000 (21:39 +0100)] 
Improve sql formatting

change {opensql} to {printsql} in prints, add missing markers

Change-Id: I07b72e6620bb64e329d6b641afa27631e91c4f16

2 years agofix ORM support for column-named bindparam() in crud .values()
Mike Bayer [Tue, 10 Jan 2023 14:51:23 +0000 (09:51 -0500)] 
fix ORM support for column-named bindparam() in crud .values()

Fixed bug / regression where using :func:`.bindparam()` with the same name
as a column in the :meth:`.Update.values` method of :class:`.Update`, as
well as the :meth:`.Insert.values` method of :class:`.Insert` in 2.0 only,
would in some cases silently fail to honor the SQL expression in which the
parameter were presented, replacing the expression with a new parameter of
the same name and discarding any other elements of the SQL expression, such
as SQL functions, etc. The specific case would be statements that were
constructed against ORM entities rather than plain :class:`.Table`
instances, but would occur if the statement were invoked with a
:class:`.Session` or a :class:`.Connection`.

:class:`.Update` part of the issue was present in both 2.0 and 1.4 and is
backported to 1.4.

Fixes: #9075
Change-Id: Ie954bc1f492ec6a566163588182ef4910c7ee452

2 years agoVersion 2.0.0rc3 placeholder
Mike Bayer [Mon, 9 Jan 2023 20:28:53 +0000 (15:28 -0500)] 
Version 2.0.0rc3 placeholder

2 years ago- 2.0.0rc2 rel_2_0_0rc2
Mike Bayer [Mon, 9 Jan 2023 20:22:47 +0000 (15:22 -0500)] 
- 2.0.0rc2

2 years agoremove anchor removed by mistake
Mike Bayer [Mon, 9 Jan 2023 20:20:39 +0000 (15:20 -0500)] 
remove anchor removed by mistake

Change-Id: I20e196f63c8cea9cd805501ab174cab320575b05

2 years agofix inconsistent title level
Mike Bayer [Mon, 9 Jan 2023 20:16:50 +0000 (15:16 -0500)] 
fix inconsistent title level

Change-Id: I954818fdf9f5b56a895dbfdaf191c4c5867b574f

2 years agoensure this is called 2.0.0rc2 in changelogs
Mike Bayer [Mon, 9 Jan 2023 20:11:34 +0000 (15:11 -0500)] 
ensure this is called 2.0.0rc2 in changelogs

Change-Id: I0a7bd45121e7234ba6f0ebca9635beb142f43a3f

2 years agoMerge "accept TableClause through mapped selectable chain" into main
mike bayer [Mon, 9 Jan 2023 19:36:36 +0000 (19:36 +0000)] 
Merge "accept TableClause through mapped selectable chain" into main

2 years agoMerge "warn and skip for FKs that refer to invisible cols for Oracle" into main
Federico Caselli [Mon, 9 Jan 2023 18:16:15 +0000 (18:16 +0000)] 
Merge "warn and skip for FKs that refer to invisible cols for Oracle" into main

2 years agoremove misleading line in post_update
Mike Bayer [Mon, 9 Jan 2023 17:38:10 +0000 (12:38 -0500)] 
remove misleading line in post_update

this UPDATE refers to the unit of work's need to consider this
additional UPDATE as a dependency and not an actual UPDATE statement.

Change-Id: I2a520af21ebf96b45c431efa898d4e7683a5bc2d
References: #9066
References: #1063

2 years agoMerge "Implement missing `#-`, `@?` and `@@` Postgres' JSONB operators." into main
mike bayer [Mon, 9 Jan 2023 14:53:20 +0000 (14:53 +0000)] 
Merge "Implement missing `#-`, `@?` and `@@` Postgres' JSONB operators." into main

2 years agowarn and skip for FKs that refer to invisible cols for Oracle
Mike Bayer [Thu, 5 Jan 2023 15:34:37 +0000 (10:34 -0500)] 
warn and skip for FKs that refer to invisible cols for Oracle

Supported use case for foreign key constraints where the local column is
marked as "invisible". The errors normally generated when a
:class:`.ForeignKeyConstraint` is created that check for the target column
are disabled when reflecting, and the constraint is skipped with a warning
in the same way which already occurs for an :class:`.Index` with a similar
issue.

tests are added for indexes, unique constraints, and primary key
constraints, which were already working; indexes and uniques warn,
primary keys don't which we would assume is because we never see those
PK columns in the first place.

Constraints now raise an informative ConstraintColumnNotFoundError
in the general case for strings in the "pending colargs" collection
not being resolvable.

Fixes: #9059
Change-Id: I400cf0bff6abba0e0c75f38b07617be1a8ec3453

2 years agoaccept TableClause through mapped selectable chain
Mike Bayer [Mon, 9 Jan 2023 13:53:57 +0000 (08:53 -0500)] 
accept TableClause through mapped selectable chain

type annotation somehow decided that TableClause doesn't have
primary key fields which is not the case at all.   In particular
the "views" recipe relies on TableClause so adding a restriction
like this does not make any sense.

It seems the issue was to open this up for typing, by allowing
TableClause out as far as ddl.sort_tables() typing is passing
for now.   Support it out in get_bind() etc.

Fixes: #9071
Change-Id: If0e22e0e7df7bee0ff4b295b0ffacfbc6b7a0142

2 years agoUse field_specifiers instead of deprecated field_descriptors
Federico Caselli [Sun, 8 Jan 2023 09:55:22 +0000 (10:55 +0100)] 
Use field_specifiers instead of deprecated field_descriptors

The Data Class Transforms argument ``field_descriptors`` was renamed
to ``field_specifiers`` in the accepted version of PEP 681.

Fixes: #9067
Change-Id: Ic13ea93c157325c3b60e65f328a364da68ea1c46

2 years agoImplement missing `#-`, `@?` and `@@` Postgres' JSONB operators.
Guilherme Martins Crocetti [Wed, 4 Jan 2023 15:27:26 +0000 (10:27 -0500)] 
Implement missing `#-`, `@?` and `@@` Postgres' JSONB operators.

Fixes #7147.
Closes: #9038
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9038
Pull-request-sha: 8647aaf2d9f48c55c152673828deb8ed54966a11

Change-Id: Id2f611ed8080a2837c70d2ea4b41abc46d2bb026

2 years agoMerge "revert MySQL to use DESCRIBE for has_table()" into main
mike bayer [Thu, 5 Jan 2023 17:55:13 +0000 (17:55 +0000)] 
Merge "revert MySQL to use DESCRIBE for has_table()" into main

2 years agorevert MySQL to use DESCRIBE for has_table()
Mike Bayer [Thu, 5 Jan 2023 04:32:23 +0000 (23:32 -0500)] 
revert MySQL to use DESCRIBE for has_table()

Restored the behavior of :meth:`.Inspector.has_table` to report on
temporary tables for MySQL / MariaDB. This is currently the behavior for
all other included dialects, but was removed for MySQL in 1.4 due to no
longer using the DESCRIBE command; there was no documented support for temp
tables being reported by the :meth:`.Inspector.has_table` method in this
version or on any previous version, so the previous behavior was undefined.

As SQLAlchemy 2.0 has added formal support for temp table status via
:meth:`.Inspector.has_table`, the MySQL /MariaDB dialect has been reverted
to use the "DESCRIBE" statement as it did in the SQLAlchemy 1.3 series and
previously, and test support is added to include MySQL / MariaDB for
this behavior.   The previous issues with ROLLBACK being emitted which
1.4 sought to improve upon don't apply in SQLAlchemy 2.0 due to
simplifications in how :class:`.Connection` handles transactions.

DESCRIBE is necessary as MariaDB in particular has no consistently
available public information schema of any kind in order to report on temp
tables other than DESCRIBE/SHOW COLUMNS, which rely on throwing an error
in order to report no results.

Fixes: #9058
Change-Id: Ic511bd5989ec17beb37b7cddd913732b626af0e6

2 years agoMerge "include parsed col length field as integer from mysql index reflection" into...
mike bayer [Thu, 5 Jan 2023 14:17:01 +0000 (14:17 +0000)] 
Merge "include parsed col length field as integer from mysql index reflection" into main

2 years agoMerge "[asyncpg] Extract rowcount for SELECT statements" into main
mike bayer [Thu, 5 Jan 2023 14:15:55 +0000 (14:15 +0000)] 
Merge "[asyncpg] Extract rowcount for SELECT statements" into main

2 years agomore thoughts on tutorial presentation of ORM /Core
Mike Bayer [Wed, 4 Jan 2023 20:17:26 +0000 (15:17 -0500)] 
more thoughts on tutorial presentation of ORM /Core

Change-Id: Iaa0c160e3f8285f1ca989dcb12b86de15ea82f03

2 years ago[asyncpg] Extract rowcount for SELECT statements
Michael Gorven [Wed, 4 Jan 2023 17:30:42 +0000 (12:30 -0500)] 
[asyncpg] Extract rowcount for SELECT statements

Added support to the asyncpg dialect to return the ``cursor.rowcount``
value for SELECT statements when available. While this is not a typical use
for ``cursor.rowcount``, the other PostgreSQL dialects generally provide
this value. Pull request courtesy Michael Gorven.

Fixes: #9048
Closes: #9049
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9049
Pull-request-sha: df16160530c6001d99de059995ad5047a75fb7b0

Change-Id: I095b866779ccea7e4d50bc841fef7605e61c667f

2 years agoinclude parsed col length field as integer from mysql index reflection
Mike Bayer [Wed, 4 Jan 2023 14:23:07 +0000 (09:23 -0500)] 
include parsed col length field as integer from mysql index reflection

Added support to MySQL index reflection to correctly reflect the
``mysql_length`` dictionary, which previously was being ignored.

Fixes: #9047
Change-Id: I0a5e27123be68741e12af4464a0fa305052ec36e

2 years agotutorial updates re: Core /ORM commonality
Mike Bayer [Tue, 3 Jan 2023 23:21:25 +0000 (18:21 -0500)] 
tutorial updates re: Core /ORM commonality

updates for Insert / bulk insert, executemanyvalues,
as well as beginning to describe Table / declared class more
closely together, mentioning typing support.

Fixed a long-standing issue where sphinx would complain about
the Insert symbol being ambiguous.

Change-Id: Id4cc09b9581e8fa39c9c00bc8f229636e626e9bc

2 years agocherry-pick changelog update for 1.4.47
Mike Bayer [Tue, 3 Jan 2023 20:17:22 +0000 (15:17 -0500)] 
cherry-pick changelog update for 1.4.47

2 years agocherry-pick changelog from 1.4.46
Mike Bayer [Tue, 3 Jan 2023 20:17:21 +0000 (15:17 -0500)] 
cherry-pick changelog from 1.4.46

2 years agoupdate wording
Mike Bayer [Tue, 3 Jan 2023 20:01:40 +0000 (15:01 -0500)] 
update wording

Change-Id: I19c7d9683218d2c059aa36dd1743661e78974976
(cherry picked from commit 02bae22e6dbaa63ca689fa5c2925e89e56e3fc52)

2 years agochangelog updates
Mike Bayer [Tue, 3 Jan 2023 19:54:14 +0000 (14:54 -0500)] 
changelog updates

Change-Id: I69581c1563f15762a9a9afae4741e23fefd76906
(cherry picked from commit f26207c7307f3449e0235a264db0fcf5b089ff73)

2 years agohappy new year 2023
Mike Bayer [Tue, 3 Jan 2023 17:45:52 +0000 (12:45 -0500)] 
happy new year 2023

Change-Id: I625af65b3fb1815b1af17dc2ef47dd697fdc3fb1

2 years agolink to with_variant() narrative from API doc
Mike Bayer [Tue, 3 Jan 2023 14:48:06 +0000 (09:48 -0500)] 
link to with_variant() narrative from API doc

Change-Id: I5d8e4d7cb7871bedebe0fe89758be441e64b94c6

2 years agoexclude pk update tests for mssql
Mike Bayer [Thu, 29 Dec 2022 19:07:32 +0000 (14:07 -0500)] 
exclude pk update tests for mssql

Change-Id: I817dacc30143fd54126cd7fe92429af858605259

2 years agoRectify reference to class LambdaElement, misnamed as LamdaElement (#9037)
Lele Gaifax [Thu, 29 Dec 2022 09:21:09 +0000 (10:21 +0100)] 
Rectify reference to class LambdaElement, misnamed as LamdaElement (#9037)

Fixes #9034.

(cherry picked from commit 532373b18f2e77910bb642a27a2cca3179499389)

2 years agoVersion 2.0.0rc2 placeholder
Mike Bayer [Wed, 28 Dec 2022 21:01:23 +0000 (16:01 -0500)] 
Version 2.0.0rc2 placeholder

2 years ago- 2.0.0rc1 rel_2_0_0rc1
Mike Bayer [Wed, 28 Dec 2022 20:55:29 +0000 (15:55 -0500)] 
- 2.0.0rc1

2 years agonote that 2.0 has behavioral changes outside of the 1.4->2.0 process
Mike Bayer [Wed, 28 Dec 2022 20:53:03 +0000 (15:53 -0500)] 
note that 2.0 has behavioral changes outside of the 1.4->2.0 process

Change-Id: I0ab9611c75f592acec73ca92271f970eae74d7ab

2 years agochangelog adjustments
Mike Bayer [Wed, 28 Dec 2022 20:30:32 +0000 (15:30 -0500)] 
changelog adjustments

include backport markings

Change-Id: I810923a641977569b8b4d9967e84b8cb684e7a52

2 years agoMerge "ensure whereclause, returning copied as tuples" into main
mike bayer [Wed, 28 Dec 2022 20:31:06 +0000 (20:31 +0000)] 
Merge "ensure whereclause, returning copied as tuples" into main

2 years agoType annotations for sqlalchemy.orm.events
Gleb Kisenkov [Wed, 28 Dec 2022 19:23:23 +0000 (14:23 -0500)] 
Type annotations for sqlalchemy.orm.events

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

### Description
An attempt to annotate `lib/sqlalchemy/orm/events.py` with type hints (issue #6810).

### Checklist
<!-- 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:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [x] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #9025
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9025
Pull-request-sha: a3fd2c0c3790164c433305ccc7ac6b73e813e037

Change-Id: I0808b6485504615fa20691dc8f4631d38bc89ab3

2 years agoensure whereclause, returning copied as tuples
Mike Bayer [Wed, 28 Dec 2022 17:04:07 +0000 (12:04 -0500)] 
ensure whereclause, returning copied as tuples

Fixed issue in the internal SQL traversal for DML statements like
:class:`_dml.Update` and :class:`_dml.Delete` which would cause among other
potential issues, a specific issue using lambda statements with the ORM
update/delete feature.

Fixes: #9033
Change-Id: I76428049cb767ba302fbea89555114bf63ab8687

2 years agoMerge "rename 2.0.0b5 to 2.0.0rc1" into main
mike bayer [Wed, 28 Dec 2022 00:01:58 +0000 (00:01 +0000)] 
Merge "rename 2.0.0b5 to 2.0.0rc1" into main

2 years agoMerge "remove errant NO_KEY symbol" into main
mike bayer [Wed, 28 Dec 2022 00:01:08 +0000 (00:01 +0000)] 
Merge "remove errant NO_KEY symbol" into main

2 years agorename 2.0.0b5 to 2.0.0rc1
Mike Bayer [Tue, 27 Dec 2022 22:28:36 +0000 (17:28 -0500)] 
rename 2.0.0b5 to 2.0.0rc1

it's hoped for 2.0.0 final to be next, in early January

Change-Id: If4285f0929f4a2895f2bc93d9e8336599b973bcf

2 years agoremove errant NO_KEY symbol
Mike Bayer [Tue, 27 Dec 2022 22:20:07 +0000 (17:20 -0500)] 
remove errant NO_KEY symbol

the symbol from base is used in the event API and is
passed along from attributes here.

for the additional use where it's an exception case for
attribute name as passed by hybrid, use a different symbol name.

Change-Id: I8c5c0e71d19185ebec64f2fcbfe1e9be74e54287

2 years agoestablish explicit join transaction modes
Mike Bayer [Tue, 20 Dec 2022 17:48:08 +0000 (12:48 -0500)] 
establish explicit join transaction modes

The behavior of "joining an external transaction into a Session" has been
revised and improved, allowing explicit control over how the
:class:`_orm.Session` will accommodate an incoming
:class:`_engine.Connection` that already has a transaction and possibly a
savepoint already established. The new parameter
:paramref:`_orm.Session.join_transaction_mode` includes a series of option
values which can accommodate the existing transaction in several ways, most
importantly allowing a :class:`_orm.Session` to operate in a fully
transactional style using savepoints exclusively, while leaving the
externally initiated transaction non-committed and active under all
circumstances, allowing test suites to rollback all changes that take place
within tests.

Additionally, revised the :meth:`_orm.Session.close` method to fully close
out savepoints that may still be present, which also allows the
"external transaction" recipe to proceed without warnings if the
:class:`_orm.Session` did not explicitly end its own SAVEPOINT
transactions.

Fixes: #9015
Change-Id: I31c22ee0fd9372fa0eddfe057e76544aee627107

2 years agoMerge "pass more contextual information to PyWrapper param create" into main
mike bayer [Tue, 27 Dec 2022 20:53:08 +0000 (20:53 +0000)] 
Merge "pass more contextual information to PyWrapper param create" into main

2 years agodont prefix ssl args with "ssl" in the ssl dict
Mike Bayer [Tue, 27 Dec 2022 20:51:06 +0000 (15:51 -0500)] 
dont prefix ssl args with "ssl" in the ssl dict

Fixes: #9031
Change-Id: I9ef077e7da5b2328a345f6526a6210ce82d807f6

2 years agopass more contextual information to PyWrapper param create
Mike Bayer [Tue, 27 Dec 2022 17:29:38 +0000 (12:29 -0500)] 
pass more contextual information to PyWrapper param create

Fixed issue in lambda SQL feature where the calculated type of a literal
value would not take into account the type coercion rules of the "compared
to type", leading to a lack of typing information for SQL expressions, such
as comparisons to :class:`.JSON` elements and similar.

Fixes: #9029
Change-Id: I381c8d7458d98ba762313dee9ec47a9c1881f74a

2 years agoMerge "reorganize pre_session_exec around do_orm_execute" into main
mike bayer [Mon, 26 Dec 2022 19:36:37 +0000 (19:36 +0000)] 
Merge "reorganize pre_session_exec around do_orm_execute" into main

2 years agoreorganize pre_session_exec around do_orm_execute
Mike Bayer [Sun, 18 Dec 2022 21:33:22 +0000 (16:33 -0500)] 
reorganize pre_session_exec around do_orm_execute

Allow do_orm_execute() events to both receive the complete
state of bind_argments, load_options, update_delete_options
as they do already, but also allow them to *change* all those
things via new execution options.   Options like autoflush,
populate_existing etc. can now be updated within a
do_orm_execute() hook and those changes will take effect
all the way through.

Took a few tries to get something that covers every case here,
in particular horizontal sharding which is consuming those
options as well as using context.invoke(), without excess
complexity.  The good news seems to be that a simple
reorg and replacing the "reentrant" boolean with
"is this before do_orm_execute is invoked" was all that was
needed.

As part of this we add a new "identity_token" option allowing
this option to be controlled from do_orm_execute() as well
as from the outside.

WIP

Fixes: #7837
Change-Id: I087728215edec8d1b1712322ab389e3f52ff76ba

2 years agoMerge "expand out Index if passed to "constraint"" into main
mike bayer [Fri, 23 Dec 2022 15:21:02 +0000 (15:21 +0000)] 
Merge "expand out Index if passed to "constraint"" into main

2 years agoimprove async_sessionmaker docs
Mike Bayer [Fri, 23 Dec 2022 14:09:44 +0000 (09:09 -0500)] 
improve async_sessionmaker docs

* illustrate patterns where the async_sessionmaker is being reused.
  if you are not reusing it, there is no point to making it
* fix reference to async_sessionmaker
* add typing

Change-Id: I22a260132b6e06574b5fe37af554829e38163de6

2 years agoexpand out Index if passed to "constraint"
Mike Bayer [Thu, 22 Dec 2022 23:14:31 +0000 (18:14 -0500)] 
expand out Index if passed to "constraint"

Fixed bug where the PostgreSQL
:paramref:`_postgresql.OnConflictClause.constraint` parameter would accept
an :class:`.Index` object, however would not expand this index out into its
individual index expressions, instead rendering its name in an ON CONFLICT
ON CONSTRAINT clause, which is not accepted by PostgreSQL; the "constraint
name" form only accepts unique or exclude constraint names. The parameter
continues to accept the index but now expands it out into its component
expressions for the render.

Fixes: #9023
Change-Id: I6baf243e26bfe578bf3f193c162dd7a623b6ede9

2 years agocheck for adapt to same class in AbstractRange
Mike Bayer [Wed, 21 Dec 2022 21:10:34 +0000 (16:10 -0500)] 
check for adapt to same class in AbstractRange

Fixed regression where newly revised PostgreSQL range types such as
:class:`_postgresql.INT4RANGE` could not be set up as the impl of a
:class:`.TypeDecorator` custom type, instead raising a ``TypeError``.

Fixes: #9020
Change-Id: Ib881c3c7f63d000f49a09185a8663659a9970aa9

2 years agoMerge "fix optimized tests, use backend=True" into main
mike bayer [Wed, 21 Dec 2022 01:32:10 +0000 (01:32 +0000)] 
Merge "fix optimized tests, use backend=True" into main

2 years agoMerge "add joins_implicitly to column_valued()" into main
mike bayer [Tue, 20 Dec 2022 20:48:33 +0000 (20:48 +0000)] 
Merge "add joins_implicitly to column_valued()" into main

2 years agofix optimized tests, use backend=True
Mike Bayer [Tue, 20 Dec 2022 16:14:26 +0000 (11:14 -0500)] 
fix optimized tests, use backend=True

A failure on one of these tests for older SQLite wasn't caught
because we did not have non-returning backends exercised

Change-Id: I4e4c96a33580942a6f82b00fc7dde83c56d4d881

2 years agoadd joins_implicitly to column_valued()
Mike Bayer [Mon, 19 Dec 2022 20:15:35 +0000 (15:15 -0500)] 
add joins_implicitly to column_valued()

Added parameter
:paramref:`.FunctionElement.column_valued.joins_implicitly`, which is
useful in preventing the "cartesian product" warning when making use of
table-valued or column-valued functions. This parameter was already
introduced for :meth:`.FunctionElement.table_valued` in :ticket:`7845`,
however it failed to be added for :meth:`.FunctionElement.column_valued`
as well.

Fixes: #9009
Change-Id: Ifb72fbcb4f4d2998e730d6f85ec7280df3bf3d47

2 years ago8393 will be backported to 1.4
Mike Bayer [Tue, 20 Dec 2022 15:49:29 +0000 (10:49 -0500)] 
8393 will be backported to 1.4

Change-Id: I54d17e8e74824826a856180c527159e0237605d4

2 years agoMerge "Add MACCADDR8 for PGCompiler" into main
mike bayer [Tue, 20 Dec 2022 15:47:30 +0000 (15:47 +0000)] 
Merge "Add MACCADDR8 for PGCompiler" into main

2 years agoMerge "remove __allow_unmapped__ requirement from dataclasses" into main
mike bayer [Mon, 19 Dec 2022 20:27:49 +0000 (20:27 +0000)] 
Merge "remove __allow_unmapped__ requirement from dataclasses" into main

2 years agoAdd MACCADDR8 for PGCompiler
asimfarooq5 [Wed, 14 Dec 2022 20:32:47 +0000 (15:32 -0500)] 
Add MACCADDR8 for PGCompiler

Add MACCADDR8 for PGCompiler

Closes: #8393
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8393
Pull-request-sha: 837a68eba3e31e0acbb7c47ee87bca4e9def7648

Change-Id: I87e4999eb8d82662ff8ab409c98dc57edd7fd271

2 years agoremove __allow_unmapped__ requirement from dataclasses
Mike Bayer [Sun, 18 Dec 2022 20:35:39 +0000 (15:35 -0500)] 
remove __allow_unmapped__ requirement from dataclasses

Removed the requirement that the ``__allow_unmapped__`` attribute be used
on Declarative Dataclass Mapped class when non-``Mapped[]`` annotations are
detected; previously, an error message that was intended to support legacy
ORM typed mappings would be raised, which additionally did not mention
correct patterns to use with Dataclasses specifically. This error message
is now no longer raised if :meth:`_orm.registry.mapped_as_dataclass` or
:class:`_orm.MappedAsDataclass` is used.

Fixes: #8973
Change-Id: I887afcc2da83dd904444bcb97f31e695b9f8b443

2 years agoadd exclusion for unusual chars in column names
Mike Bayer [Mon, 19 Dec 2022 13:34:51 +0000 (08:34 -0500)] 
add exclusion for unusual chars in column names

Added new exclusion rule for third party dialects called
``unusual_column_name_characters``, which can be "closed" for third party
dialects that don't support column names with unusual characters such as
dots, slashes, or percent signs in them, even if the name is properly
quoted.

Fixes: #9002
Change-Id: I44b765df4c73ce5ec1907d031fd9c89761fd99d1
References: #8993

2 years agoMerge "include pk cols in refresh() if relationships are requested" into main
mike bayer [Sun, 18 Dec 2022 20:02:39 +0000 (20:02 +0000)] 
Merge "include pk cols in refresh() if relationships are requested" into main

2 years agoinclude pk cols in refresh() if relationships are requested
Mike Bayer [Fri, 16 Dec 2022 20:44:32 +0000 (15:44 -0500)] 
include pk cols in refresh() if relationships are requested

A series of changes and improvements regarding
:meth:`_orm.Session.refresh`. The overall change is that primary key
attributes for an object are now included in a refresh operation
unconditionally when relationship-bound attributes are to be refreshed,
even if not expired and even if not specified in the refresh.

* Improved :meth:`_orm.Session.refresh` so that if autoflush is enabled
(as is the default for :class:`_orm.Session`), the autoflush takes place
at an earlier part of the refresh process so that pending primary key
changes are applied without errors being raised.  Previously, this
autoflush took place too late in the process and the SELECT statement
would not use the correct key to locate the row and an
:class:`.InvalidRequestError` would be raised.

* When the above condition is present, that is, unflushed primary key
changes are present on the object, but autoflush is not enabled,
the refresh() method now explicitly disallows the operation to proceed,
and an informative :class:`.InvalidRequestError` is raised asking that
the pending primary key changes be flushed first.  Previously,
this use case was simply broken and :class:`.InvalidRequestError`
would be raised anyway. This restriction is so that it's safe for the
primary key attributes to be refreshed, as is necessary for the case of
being able to refresh the object with relationship-bound secondary
eagerloaders also being emitted. This rule applies in all cases to keep
API behavior consistent regardless of whether or not the PK cols are
actually needed in the refresh, as it is unusual to be refreshing
some attributes on an object while keeping other attributes "pending"
in any case.

* The :meth:`_orm.Session.refresh` method has been enhanced such that
attributes which are :func:`_orm.relationship`-bound and linked to an
eager loader, either at mapping time or via last-used loader options,
will be refreshed in all cases even when a list of attributes is passed
that does not include any columns on the parent row. This builds upon the
feature first implemented for non-column attributes as part of
:ticket:`1763` fixed in 1.4 allowing eagerly-loaded relationship-bound
attributes to participate in the :meth:`_orm.Session.refresh` operation.
If the refresh operation does not indicate any columns on the parent row
to be refreshed, the primary key columns will nonetheless be included
in the refresh operation, which allows the load to proceed into the
secondary relationship loaders indicated as it does normally.
Previously an :class:`.InvalidRequestError` error would be raised
for this condition (:ticket:`8703`)

* Fixed issue where an unnecessary additional SELECT would be emitted in
the case where :meth:`_orm.Session.refresh` were called with a
combination of expired attributes, as well as an eager loader such as
:func:`_orm.selectinload` that emits a "secondary" query, if the primary
key attributes were also in an expired state.  As the primary key
attributes are now included in the refresh automatically, there is no
additional load for these attributes when a relationship loader
goes to select for them (:ticket:`8997`)

* Fixed regression caused by :ticket:`8126` released in 2.0.0b1 where the
:meth:`_orm.Session.refresh` method would fail with an
``AttributeError``, if passed both an expired column name as well as the
name of a relationship-bound attribute that was linked to a "secondary"
eagerloader such as the :func:`_orm.selectinload` eager loader
(:ticket:`8996`)

Fixes: #8703
Fixes: #8996
Fixes: #8997
Fixes: #8126
Change-Id: I88dcbc0a9a8337f6af0bc4bcc5b0261819acd1c4

2 years agoMerge "dont call platform.architecture()" into main
mike bayer [Sun, 18 Dec 2022 06:26:11 +0000 (06:26 +0000)] 
Merge "dont call platform.architecture()" into main

2 years agofix changelog for types, add date rendering to whatsnew
Mike Bayer [Sat, 17 Dec 2022 16:10:02 +0000 (11:10 -0500)] 
fix changelog for types, add date rendering to whatsnew

this change is likely somehting people want to see so make
it more prominent, also there's no "types" category in changelog
so these should be "sql".

Change-Id: I9104c210448f3ba0304f1e09d0613240fe8dcf4e
References: #8998

2 years agoMerge "ensure all visit methods accept **kw" into main
mike bayer [Sat, 17 Dec 2022 02:02:33 +0000 (02:02 +0000)] 
Merge "ensure all visit methods accept **kw" into main

2 years agoMerge "make bind escape lookup extensible" into main
mike bayer [Fri, 16 Dec 2022 19:37:51 +0000 (19:37 +0000)] 
Merge "make bind escape lookup extensible" into main

2 years agodont call platform.architecture()
Mike Bayer [Fri, 16 Dec 2022 19:05:48 +0000 (14:05 -0500)] 
dont call platform.architecture()

Fixed regression where the base compat module was calling upon
``platform.architecture()`` in order to detect some system properties,
which results in an over-broad system call against the system-level
``file`` call that is unavailable under some circumstances, including
within some secure environment configurations.

Fixes: #8995
Change-Id: Ib6171e75aff5a60a79dab81a0be21bee2456318b

2 years agoensure all visit methods accept **kw
Mike Bayer [Fri, 16 Dec 2022 17:16:21 +0000 (12:16 -0500)] 
ensure all visit methods accept **kw

Added test support to ensure that all compiler ``visit_xyz()`` methods
across all :class:`.Compiler` implementations in SQLAlchemy accept a
``**kw`` parameter, so that all compilers accept additional keyword
arguments under all circumstances.

Fixes: #8988
Change-Id: I1cefc313e4e64a10ee7dd14400137fbe02ce9523

2 years agomake bind escape lookup extensible
Mike Bayer [Fri, 16 Dec 2022 17:56:21 +0000 (12:56 -0500)] 
make bind escape lookup extensible

To accommodate for third party dialects with different character escaping
needs regarding bound parameters, the system by which SQLAlchemy "escapes"
(i.e., replaces with another character in its place) special characters in
bound parameter names has been made extensible for third party dialects,
using the :attr:`.SQLCompiler.bindname_escape_chars` dictionary which can
be overridden at the class declaration level on any :class:`.SQLCompiler`
subclass. As part of this change, also added the dot ``"."`` as a default
"escaped" character.

Fixes: #8994
Change-Id: I52fbbfa8c64497b123f57327113df3f022bd1419

2 years agoMerge "add eager_defaults="auto" for inserts" into main
mike bayer [Fri, 16 Dec 2022 16:56:56 +0000 (16:56 +0000)] 
Merge "add eager_defaults="auto" for inserts" into main

2 years agoMerge "implement literal_binds with expanding + bind_expression" into main
mike bayer [Fri, 16 Dec 2022 15:08:18 +0000 (15:08 +0000)] 
Merge "implement literal_binds with expanding + bind_expression" into main

2 years agoMerge "add explicit REGCONFIG, pg full text functions" into main
mike bayer [Fri, 16 Dec 2022 15:08:00 +0000 (15:08 +0000)] 
Merge "add explicit REGCONFIG, pg full text functions" into main

2 years agoMerge "Improved error message in orm annotated declarative" into main
mike bayer [Fri, 16 Dec 2022 15:01:06 +0000 (15:01 +0000)] 
Merge "Improved error message in orm annotated declarative" into main

2 years agoMerge "Improve v2 documentation" into main
mike bayer [Thu, 15 Dec 2022 22:32:15 +0000 (22:32 +0000)] 
Merge "Improve v2 documentation" into main