]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
2 years agocopy deferred attributes for mapped_column
Mike Bayer [Thu, 30 Mar 2023 16:55:45 +0000 (12:55 -0400)] 
copy deferred attributes for mapped_column

Fixed issue where the :func:`_orm.mapped_column` construct would raise an
internal error if used on a Declarative mixin and included the
:paramref:`_orm.mapped_column.deferred` parameter.

Fixes: #9550
Change-Id: I0cc5ec4910656abc9a3fb7b7b60880256cd7c61e

2 years agoMerge "warn for all unmapped expressions" into main
mike bayer [Thu, 30 Mar 2023 14:17:30 +0000 (14:17 +0000)] 
Merge "warn for all unmapped expressions" into main

2 years agoadd mypy issue 13856 to bug reporting template
Mike Bayer [Thu, 30 Mar 2023 14:14:23 +0000 (10:14 -0400)] 
add mypy issue 13856 to bug reporting template

Change-Id: Ie25810bfb188794858ba39e246a72b06c484e474
References: #9567

2 years agoMerge "disable raise sql for the delete cascade" into main
mike bayer [Wed, 29 Mar 2023 13:15:55 +0000 (13:15 +0000)] 
Merge "disable raise sql for the delete cascade" into main

2 years agoMerge "Improve from_select typing" into main
mike bayer [Tue, 28 Mar 2023 22:05:23 +0000 (22:05 +0000)] 
Merge "Improve from_select typing" into main

2 years agodisable raise sql for the delete cascade
Mike Bayer [Sun, 26 Mar 2023 16:30:35 +0000 (12:30 -0400)] 
disable raise sql for the delete cascade

Towards maintaining consistency with unit-of-work changes made for
:ticket:`5984` and :ticket:`8862`, both of which disable "lazy='raise'"
handling within :class:`_orm.Session` processes that aren't triggered by
attribute access, the :meth:`_orm.Session.delete` method will now also
disable "lazy='raise'" handling when it traverses relationship paths in
order to process the "delete" and "delete-orphan" cascade rules.
Previously, there was no easy way to generically call
:meth:`_orm.Session.delete` on an object that had "lazy='raise'" set up
such that only the necessary relationships would be loaded. As
"lazy='raise'" is primarily intended to catch SQL loading that emits on
attribute access, :meth:`_orm.Session.delete` is now made to behave like
other :class:`_orm.Session` methods including :meth:`_orm.Session.merge` as
well as :meth:`_orm.Session.flush` along with autoflush.

Fixes: #9549
Change-Id: Ie049e66ce2bd35900eae4af0e9b795633303ca63

2 years agoImprove from_select typing
Federico Caselli [Mon, 27 Mar 2023 20:03:44 +0000 (22:03 +0200)] 
Improve from_select typing

Properly type :paramref:`_dml.Insert.from_select.names` to accept
a list of string or columns or mapped attributes.
Fixes: #9514
Change-Id: I2a3396454e79bd2113fc3d57d1252a2e6d141310

2 years agoMerge "check for recursion with container types" into main
mike bayer [Mon, 27 Mar 2023 23:34:46 +0000 (23:34 +0000)] 
Merge "check for recursion with container types" into main

2 years agoMerge "support DeclarativeBase for versioned history example" into main
mike bayer [Mon, 27 Mar 2023 23:33:02 +0000 (23:33 +0000)] 
Merge "support DeclarativeBase for versioned history example" into main

2 years agocheck for recursion with container types
Mike Bayer [Mon, 27 Mar 2023 14:19:32 +0000 (10:19 -0400)] 
check for recursion with container types

Fixed issue in ORM Annotated Declarative where using a recursive type (e.g.
using a nested Dict type) would result in a recursion overflow in the ORM's
annotation resolution logic, even if this datatype were not necessary to
map the column.

Fixes: #9553
Change-Id: Ied99dc0d47276c6e9c23fa9df5fc65f7736d65cf

2 years agoFix creating zero length char with MySQL dialect
J. Nick Koston [Sun, 26 Mar 2023 02:00:25 +0000 (22:00 -0400)] 
Fix creating zero length char with MySQL dialect

Fixed issue where string datatypes such as :class:`.CHAR`,
:class:`.VARCHAR`, :class:`.TEXT`, as well as binary :class:`.BLOB`, could
not be produced with an explicit length of zero, which has special meaning
for MySQL. Pull request courtesy J. Nick Koston.

Fixes: #9544
Closes: #9543
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9543
Pull-request-sha: dc17fc3e93f0ba90881c4efb06016ddf83c7af8b

Change-Id: I96925d45f16887f5dfd68a5d4f9284b3abc46d25

2 years agosupport DeclarativeBase for versioned history example
Mike Bayer [Mon, 27 Mar 2023 13:48:58 +0000 (09:48 -0400)] 
support DeclarativeBase for versioned history example

Fixed issue in "versioned history" example where using a declarative base
that is derived from :class:`_orm.DeclarativeBase` would fail to be mapped.
Additionally, repaired the given test suite so that the documented
instructions for running the example using Python unittest now work again.

Change-Id: I164a5b8dbdd01e3d815eb356f7b7cadf226ca296
References: #9546

2 years agodocs: 📚 fix duplicate word typo (#9539)
Tom Wolfskämpf [Sat, 25 Mar 2023 17:45:37 +0000 (17:45 +0000)] 
docs: ðŸ“š fix duplicate word typo (#9539)

2 years agoMerge "automatically provision hstore for pg13+" into main
mike bayer [Sat, 25 Mar 2023 13:51:12 +0000 (13:51 +0000)] 
Merge "automatically provision hstore for pg13+" into main

2 years agowarn for all unmapped expressions
Mike Bayer [Fri, 24 Mar 2023 15:11:54 +0000 (11:11 -0400)] 
warn for all unmapped expressions

Expanded the warning emitted when a plain :func:`_sql.column` object is
present in a Declarative mapping to include any arbitrary SQL expression
that is not declared within an appropriate property type such as
:func:`_orm.column_property`, :func:`_orm.deferred`, etc. These attributes
are otherwise not mapped at all and remain unchanged within the class
dictionary. As it seems likely that such an expression is usually not
what's intended, this case now warns for all such otherwise ignored
expressions, rather than just the :func:`_sql.column` case.

Fixes: #9537
Change-Id: Ic4ca7a071a28adf4ea8680690025d927522a0805

2 years agoMerge "use clone, not constructor, in BindParameter.render_literal_execute()" into...
mike bayer [Wed, 22 Mar 2023 23:54:57 +0000 (23:54 +0000)] 
Merge "use clone, not constructor, in BindParameter.render_literal_execute()" into main

2 years agouse clone, not constructor, in BindParameter.render_literal_execute()
Mike Bayer [Wed, 22 Mar 2023 15:56:04 +0000 (11:56 -0400)] 
use clone, not constructor, in BindParameter.render_literal_execute()

Fixed issue where the :meth:`_sql.BindParameter.render_literal_execute`
method would fail when called on a parameter that also had ORM annotations
associated with it. In practice, this would be observed as a failure of SQL
compilation when using some combinations of a dialect that uses "FETCH
FIRST" such as Oracle along with a :class:`_sql.Select` construct that uses
:meth:`_sql.Select.limit`, within some ORM contexts, including if the
statement were embedded within a relationship primaryjoin expression.

Fixes: #9526
Change-Id: I2f512b6760a90293d274e60b06a891f10b276ecc

2 years agoMerge "return None for no parententity on Proxy" into main
mike bayer [Wed, 22 Mar 2023 15:29:41 +0000 (15:29 +0000)] 
Merge "return None for no parententity on Proxy" into main

2 years agofix update in nested_sets example
Mike Bayer [Tue, 21 Mar 2023 18:43:46 +0000 (14:43 -0400)] 
fix update in nested_sets example

Fixes: #9520
Change-Id: I3dbf62bd9b70fb226cf7c641719df8ac53ec1427

2 years agoadd tip that reflection is not necessary for an existing database
Mike Bayer [Tue, 21 Mar 2023 17:40:36 +0000 (13:40 -0400)] 
add tip that reflection is not necessary for an existing database

a new user spent many days misled by this paragraph thinking
they were required to use reflection for an existing database.

Change-Id: I4c6757b931481db7a8d4202334382143e1491935

2 years agoreturn None for no parententity on Proxy
Mike Bayer [Tue, 21 Mar 2023 17:32:41 +0000 (13:32 -0400)] 
return None for no parententity on Proxy

Fixed regression where accessing the expression value of a hybrid property
on a class that was either unmapped or not-yet-mapped (such as calling upon
it within a :func:`_orm.declared_attr` method) would raise an internal
error, as an internal fetch for the parent class' mapper would fail and an
instruction for this failure to be ignored were inadvertently removed in
2.0.

Fixes: #9519
Change-Id: If195d26a5ddd2312a373004eb7a1403e1d11e7a4

2 years agodont render VARCHAR length for PG casts
Mike Bayer [Sun, 19 Mar 2023 14:37:15 +0000 (10:37 -0400)] 
dont render VARCHAR length for PG casts

Fixed critical regression in PostgreSQL dialects such as asyncpg which rely
upon explicit casts in SQL in order for datatypes to be passed to the
driver correctly, where a :class:`.String` datatype would be cast along
with the exact column length being compared, leading to implicit truncation
when comparing a ``VARCHAR`` of a smaller length to a string of greater
length regardless of operator in use (e.g. LIKE, MATCH, etc.). The
PostgreSQL dialect now omits the length from ``VARCHAR`` when rendering
these casts.

Fixes: #9511
Change-Id: If094146d8cfd989a0b780872f38e86fd41ebfec2

2 years agocherry-pick changelog update for 1.4.48
Mike Bayer [Sat, 18 Mar 2023 17:09:08 +0000 (13:09 -0400)] 
cherry-pick changelog update for 1.4.48

2 years agocherry-pick changelog from 1.4.47
Mike Bayer [Sat, 18 Mar 2023 17:09:08 +0000 (13:09 -0400)] 
cherry-pick changelog from 1.4.47

2 years agoVersion 2.0.8 placeholder
Mike Bayer [Sat, 18 Mar 2023 17:04:40 +0000 (13:04 -0400)] 
Version 2.0.8 placeholder

2 years ago- 2.0.7 rel_2_0_7
Mike Bayer [Sat, 18 Mar 2023 16:56:40 +0000 (12:56 -0400)] 
- 2.0.7

2 years agoadd forwards port
Mike Bayer [Sat, 18 Mar 2023 16:56:18 +0000 (12:56 -0400)] 
add forwards port

Change-Id: If82a883fef40d3cf4717b927024b0b83a8e47a5d

2 years agoimplement content hashing for custom_op, not identity
Mike Bayer [Sat, 18 Mar 2023 15:43:47 +0000 (11:43 -0400)] 
implement content hashing for custom_op, not identity

Fixed critical SQL caching issue where use of the :meth:`_sql.Operators.op`
custom operator function would not produce an appropriate cache key,
leading to reduce the effectiveness of the SQL cache.

Fixes: #9506
Change-Id: I3eab1ddb5e09a811ad717161a59df0884cdf70ed

2 years agoMerge "add explicit overload for composite -> callable" into main
mike bayer [Fri, 17 Mar 2023 18:34:57 +0000 (18:34 +0000)] 
Merge "add explicit overload for composite -> callable" into main

2 years agoMerge "Improved wheel pipeline" into main
mike bayer [Fri, 17 Mar 2023 14:49:57 +0000 (14:49 +0000)] 
Merge "Improved wheel pipeline" into main

2 years agoImproved wheel pipeline
Federico Caselli [Wed, 15 Mar 2023 20:49:13 +0000 (21:49 +0100)] 
Improved wheel pipeline

- ensure that the compiled extensions are used
- speed up job by parallelizing more

Fixes: #9434
Change-Id: Ief750b28733ba24bb5ff8c105e1a4c9b7b928700

2 years agoadd explicit overload for composite -> callable
Mike Bayer [Fri, 17 Mar 2023 12:35:56 +0000 (08:35 -0400)] 
add explicit overload for composite -> callable

Fixed typing issue where :func:`_orm.composite` would not allow an
arbitrary callable as the source of the composite class.

Fixes: #9502
Change-Id: I5b098b70b2fb7b48f54eaccbb7d5d3d9bdebc781

2 years agoMerge "Add override hook PGDialect.set_backslash_escapes()" into main
mike bayer [Wed, 15 Mar 2023 22:25:00 +0000 (22:25 +0000)] 
Merge "Add override hook PGDialect.set_backslash_escapes()" into main

2 years agoMerge "use utc for datetimetz multirange tests" into main
mike bayer [Wed, 15 Mar 2023 22:24:33 +0000 (22:24 +0000)] 
Merge "use utc for datetimetz multirange tests" into main

2 years agoautomatically provision hstore for pg13+
Federico Caselli [Wed, 15 Mar 2023 19:23:40 +0000 (20:23 +0100)] 
automatically provision hstore for pg13+

Change-Id: I5cd7e9e9ab8a1dae2bd467a1e4299d7f26183301

2 years agoImplementation of CITEXT , unittest and documentation
Julian David Rath [Mon, 6 Mar 2023 20:50:48 +0000 (15:50 -0500)] 
Implementation of CITEXT , unittest and documentation

Added new PostgreSQL type :class:`_postgresql.CITEXT`. Pull request
courtesy Julian David Rath.

Fixes: #9416
Closes: #9417
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9417
Pull-request-sha: 23a83a342ad6d820ee5749ebccda04e54c373f7d

Change-Id: I54699b9457426c20afbdc0acaa41dc57644b0536

2 years agoremove "listeners" docstring
Mike Bayer [Wed, 15 Mar 2023 14:09:57 +0000 (10:09 -0400)] 
remove "listeners" docstring

this should have been removed with #4638.

Fixes: #9492
Change-Id: If82dba7e63382e921aceb0c01d88f0977b7f5e8d

2 years agoDocument generic type parameters to FunctionElement and GenericFunction (#9079)
Stephen Rosen [Tue, 14 Mar 2023 19:18:14 +0000 (14:18 -0500)] 
Document generic type parameters to FunctionElement and GenericFunction (#9079)

* Document type parameters to FunctionElement

Add a note to FunctionElement which indicates that the type is a
typing.Generic class and points at GenericFunction examples for a
specific example usage.

A minimal reference is made to type checkers and IDEs as use-cases in
order to try to contextualize this as an optional feature which
supports particular use cases.

Append to the GenericFunction examples a case which uses `DateTime`
but also includes the generic type parameter (`datetime.datetime`).

* Fix type annotated function usage example

2 years agouse utc for datetimetz multirange tests
Mike Bayer [Tue, 14 Mar 2023 13:16:25 +0000 (09:16 -0400)] 
use utc for datetimetz multirange tests

these tests failed the day before DST here, so just use utc

Fixes: #9471
Change-Id: I3f5c940b4e7d36943bd3ad34cc06b9563371d171

2 years agoBump pypa/cibuildwheel from 2.12.0 to 2.12.1 (#9474)
dependabot[bot] [Mon, 13 Mar 2023 18:42:15 +0000 (19:42 +0100)] 
Bump pypa/cibuildwheel from 2.12.0 to 2.12.1 (#9474)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 years agoAdd override hook PGDialect.set_backslash_escapes()
Matt del Valle [Mon, 13 Mar 2023 18:38:31 +0000 (14:38 -0400)] 
Add override hook PGDialect.set_backslash_escapes()

### Description
Refactor out the lines in `PGDialect.initialize()` that set backslash escapes into their own method to provide an override hook for [`sqlalchemy-redshift`](https://github.com/sqlalchemy-redshift/sqlalchemy-redshift) to use.

Fixes #9442

### Checklist

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] 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.

Closes: #9475
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9475
Pull-request-sha: 5565afeac20ea3612c3f427f58efacd8487ac159

Change-Id: I9b652044243ab231c19ab55ebc8ee24534365d61

2 years agoVersion 2.0.7 placeholder
Mike Bayer [Mon, 13 Mar 2023 17:36:12 +0000 (13:36 -0400)] 
Version 2.0.7 placeholder

2 years ago- 2.0.6 rel_2_0_6
Mike Bayer [Mon, 13 Mar 2023 16:44:14 +0000 (12:44 -0400)] 
- 2.0.6

2 years agosimplify AttachedDB test for SQLite
Mike Bayer [Mon, 13 Mar 2023 16:19:03 +0000 (12:19 -0400)] 
simplify AttachedDB test for SQLite

This test is failing on windows due to the new SQlite
provisioning that seemed to be failing to delete schema files
as they are still used by the main connection.

Change-Id: I51093212ebfe1053f26b279c56c8fec0408806da

2 years agodocument no-pep681 workarounds
Mike Bayer [Sat, 11 Mar 2023 15:38:44 +0000 (10:38 -0500)] 
document no-pep681 workarounds

Mypy 1.1.1 has been released which includes a non-compliant pep-681
implementation that fails with SQLAlchemy's :class:`.MappedAsDataclass` and
similar features. In order to work around this issue until Mypy is able to
release a fix, as well as to support other typing tools which may have
non-compliant pep-681 implementations, document a workaround class
for :class:`.MappedAsDataclass`.

Including this class as well as a decorator was considered, but overall
this is an issue with typing tools that they will have to resolve
and I'm not ready to set up for this issue going on long term.  There's
also no good solution for the decorator version since you have to
have an ``__init__`` method indicated somewhere.

References: https://github.com/python/mypy/issues/13856
Fixes: #9467
Change-Id: I1be6abea7f7fc72883c14ab2447edad937d0c23f

2 years agofix unlengthed string used as pk
Mike Bayer [Sat, 11 Mar 2023 06:51:20 +0000 (01:51 -0500)] 
fix unlengthed string used as pk

SQL Server has been failing on this test for a month as it does
not allow a PK on VARCHAR(max)

Change-Id: I3f43e660275e03ced1b584fe9d3c7f34f5558330

2 years agoMerge "sqlite provisioning is ridiculous" into main
mike bayer [Sat, 11 Mar 2023 06:48:10 +0000 (06:48 +0000)] 
Merge "sqlite provisioning is ridiculous" into main

2 years agosqlite provisioning is ridiculous
Mike Bayer [Fri, 10 Mar 2023 20:17:30 +0000 (15:17 -0500)] 
sqlite provisioning is ridiculous

try to get file naming to be more sane for pysqlite file databases

Change-Id: I68ad8c2f6c6c25930fbffdd79b8d429cd7a7dd9a

2 years agoMerge "Fix regression when deserializing python rows into cython" into main
mike bayer [Fri, 10 Mar 2023 21:06:28 +0000 (21:06 +0000)] 
Merge "Fix regression when deserializing python rows into cython" into main

2 years agoMerge "repair broken lambda patch" into main
mike bayer [Fri, 10 Mar 2023 21:05:35 +0000 (21:05 +0000)] 
Merge "repair broken lambda patch" into main

2 years agorepair broken lambda patch
Mike Bayer [Thu, 9 Mar 2023 18:54:07 +0000 (13:54 -0500)] 
repair broken lambda patch

in I4e0b627bfa187f1780dc68ec81b94db1c78f846a the 1.4 version has more
changes than the main version, which failed to get the entire change,
yet the whole thing was merged.   Restore the missing mutex related
code to the main version.

Fixed regression where the fix for :ticket:`8098`, which was released in
the 1.4 series and provided a layer of concurrency-safe checks for the
lambda SQL API, included additional fixes in the patch that failed to be
applied to the main branch. These additional fixes have been applied.

Change-Id: Id172e09c421dafa6ef1d40b383aa4371de343864
References: #8098
Fixes: #9461
2 years agoMerge "implement active_history for composites" into main
mike bayer [Fri, 10 Mar 2023 15:28:09 +0000 (15:28 +0000)] 
Merge "implement active_history for composites" into main

2 years agoFix regression when deserializing python rows into cython
Federico Caselli [Mon, 6 Mar 2023 23:25:59 +0000 (00:25 +0100)] 
Fix regression when deserializing python rows into cython

Fixed regression involving pickling of Python rows between the cython and
pure Python implementations of :class:`.Row`, which occurred as part of
refactoring code for version 2.0 with typing. A particular constant were
turned into a string based ``Enum`` for the pure Python version of
:class:`.Row` whereas the cython version continued to use an integer
constant, leading to deserialization failures.

Regression occurred in a4bb502cf95ea3523e4d383c4377e50f402d7d52

Fixes: #9423
Change-Id: Icbd85cacb2d589cef7c246de7064249926146f2e

2 years agodenormalize "public" schema to "PUBLIC"
Mike Bayer [Thu, 9 Mar 2023 16:49:46 +0000 (11:49 -0500)] 
denormalize "public" schema to "PUBLIC"

Fixed reflection bug where Oracle "name normalize" would not work correctly
for reflection of symbols that are in the "PUBLIC" schema, such as
synonyms, meaning the PUBLIC name could not be indicated as lower case on
the Python side for the :paramref:`_schema.Table.schema` argument. Using
uppercase "PUBLIC" would work, but would then lead to awkward SQL queries
including a quoted ``"PUBLIC"`` name as well as indexing the table under
uppercase "PUBLIC", which was inconsistent.

Fixes: #9459
Change-Id: I989bd1e794a5b5ac9aae4f4a8702f14c56cd74c2

2 years agoimplement active_history for composites
Mike Bayer [Thu, 9 Mar 2023 17:41:03 +0000 (12:41 -0500)] 
implement active_history for composites

Fixed bug where the "active history" feature was not fully
implemented for composite attributes, making it impossible to receive
events that included the "old" value.   This seems to have been the case
with older SQLAlchemy versions as well, where "active_history" would
be propagated to the underlying column-based attributes, but an event
handler listening to the composite attribute itself would not be given
the "old" value being replaced, even if the composite() were set up
with active_history=True.

Additionally, fixed a regression that's local to 2.0 which disallowed
active_history on composite from being assigned to the impl with
``attr.impl.active_history=True``.

Fixes: #9460
Change-Id: I6d7752a01c8d3fd78de7a90de10e8c52f9b3cd4e

2 years agoMerge "Use independent TypeVar for ColumnElement.cast" into main
mike bayer [Thu, 9 Mar 2023 00:22:10 +0000 (00:22 +0000)] 
Merge "Use independent TypeVar for ColumnElement.cast" into main

2 years agoclarify "selecting individual columns" doc
Mike Bayer [Wed, 8 Mar 2023 22:23:31 +0000 (17:23 -0500)] 
clarify "selecting individual columns" doc

Just went to refer to this and it was full of difficult terminology
for no good reason.   What's troubling is that this doc is like the
tenth time I've rewritten this and it still was loaded with too
much jargon and not clear about the behavior.

Change-Id: I22745962568277eead6081a82003ac90665048e0

2 years agoUse independent TypeVar for ColumnElement.cast
Mike Bayer [Wed, 8 Mar 2023 17:35:27 +0000 (12:35 -0500)] 
Use independent TypeVar for ColumnElement.cast

Fixed typing issue where :meth:`.ColumnElement.cast` did not allow a
:class:`.TypeEngine` argument independent of the type of the
:class:`.ColumnElement` itself, which is the purpose of
:meth:`.ColumnElement.cast`.

Fixes: #9451
Change-Id: I68119c6a9e8bf896715eea79be2b4f36b1c141de

2 years agoupdate for mypy 1.1.1
Mike Bayer [Wed, 8 Mar 2023 17:14:01 +0000 (12:14 -0500)] 
update for mypy 1.1.1

looks like mypy 1.1.1 slipped in after the last jenkins pep484 build
for SQLAlchemy.  update for its new issues.

Change-Id: Ifca967a75d5e592c04b0138aeda9b646067fe59b

2 years agoadditional consistency for ORM/Core in tutorial
Mike Bayer [Wed, 8 Mar 2023 15:10:14 +0000 (10:10 -0500)] 
additional consistency for ORM/Core in tutorial

* Make sure we have blue borders for all sections
* rewrite "blue border" text, refer to textual means of determining
  subject matter for a section; "blue borders" are not a primary
  source of information
* Add some more intro text that was missing

Change-Id: I4d599e13d23bad8bb3c199a11afb53e3e9100c59
References: #9450

2 years agoresolve select to NULLTYPE if no columns
Mike Bayer [Tue, 7 Mar 2023 14:03:07 +0000 (09:03 -0500)] 
resolve select to NULLTYPE if no columns

Fixed regression where the :func:`_sql.select` construct would not be able
to render if it were given no columns and then used in the context of an
EXISTS, raising an internal exception instead. While an empty "SELECT" is
not typically valid SQL, in the context of EXISTS databases such as
PostgreSQL allow it, and in any case the condition now no longer raises
an internal exception.

For this case, also add an extra whitespace trim step for the unusual
case that there are no columns to render.  This is done in such a
way as to not interfere with other test cases that are involving
custom compilation schemes.

Fixes: #9440
Change-Id: If65ba9ce15d371f09b4342ad0669143b7b082a78

2 years agoupdate sql server use_setinputsizes docs a bit
Mike Bayer [Tue, 7 Mar 2023 03:26:33 +0000 (22:26 -0500)] 
update sql server use_setinputsizes docs a bit

the verbiage here was ambiguous previously.

Change-Id: I452ae85bd8b5469d4103970e99cfac752b508274

2 years agoVersion 2.0.6 placeholder
Mike Bayer [Mon, 6 Mar 2023 03:42:43 +0000 (22:42 -0500)] 
Version 2.0.6 placeholder

2 years ago- 2.0.5.post1 rel_2_0_5_post1
Mike Bayer [Mon, 6 Mar 2023 03:32:07 +0000 (22:32 -0500)] 
- 2.0.5.post1

2 years agoremove release date
Mike Bayer [Mon, 6 Mar 2023 03:31:24 +0000 (22:31 -0500)] 
remove release date

Change-Id: I8721674372673d0b242e1e07d3fc9b7ff7256c48

2 years agocomment out pickle/ process test and attempt 2.0.5.post1
Mike Bayer [Mon, 6 Mar 2023 03:25:46 +0000 (22:25 -0500)] 
comment out pickle/ process test and attempt 2.0.5.post1

if .post1 fails to work out, we'll just do 2.0.6

The test_pickle_rows_other_process test is failing during wheel
builds as it seems that the "subprocess" run is not using the
cython extensions, leading to a pickle mismatch between the
cythonized and the pure python version of a row.  comment
out this test and attempt to release as 2.0.5.post1 so that
wheels can build.

Fixes: #9429
Change-Id: I6e1e9f2b9c4ef8fa67a88ff86ebdacbeb02b90df

2 years agoVersion 2.0.6 placeholder
Mike Bayer [Mon, 6 Mar 2023 01:59:39 +0000 (20:59 -0500)] 
Version 2.0.6 placeholder

2 years ago- 2.0.5 rel_2_0_5
Mike Bayer [Mon, 6 Mar 2023 00:55:20 +0000 (19:55 -0500)] 
- 2.0.5

2 years ago(lots of) changelog updates for 2.0.5
Mike Bayer [Mon, 6 Mar 2023 00:54:30 +0000 (19:54 -0500)] 
(lots of) changelog updates for 2.0.5

Change-Id: Iea2ca2cd1eb44b4e9139f2bb6c3d6239f67aeb56

2 years agoMerge "KeyFuncDict regression fixes and dataclass fixes" into main
mike bayer [Mon, 6 Mar 2023 00:31:10 +0000 (00:31 +0000)] 
Merge "KeyFuncDict regression fixes and dataclass fixes" into main

2 years agoKeyFuncDict regression fixes and dataclass fixes
Mike Bayer [Sat, 4 Mar 2023 20:31:41 +0000 (15:31 -0500)] 
KeyFuncDict regression fixes and dataclass fixes

adapt None-key warning for non-mapped attributes

Fixed multiple regressions due to :ticket:`8372`, involving
:func:`_orm.attribute_mapped_collection` (now called
:func:`_orm.attribute_keyed_dict`).

First, the collection was no longer usable with "key" attributes that were
not themselves ordinary mapped attributes; attributes linked to descriptors
and/or association proxy attributes have been fixed.

Second, if an event or other operation needed access to the "key" in order
to populate the dictionary from an mapped attribute that was not
loaded, this also would raise an error inappropriately, rather than
trying to load the attribute as was the behavior in 1.4.  This is also
fixed.

For both cases, the behavior of :ticket:`8372` has been expanded.
:ticket:`8372` introduced an error that raises when the derived key that
would be used as a mapped dictionary key is effectively unassigned. In this
change, a warning only is emitted if the effective value of the ".key"
attribute is ``None``, where it cannot be unambiguously determined if this
``None`` was intentional or not. ``None`` will be not supported as mapped
collection dictionary keys going forward (as it typically refers to NULL
which means "unknown"). Setting
:paramref:`_orm.attribute_keyed_dict.ignore_unpopulated_attribute` will now
cause such ``None`` keys to be ignored as well.

Add value constructors to dictionary collections

Added constructor arguments to the built-in mapping collection types
including :class:`.KeyFuncDict`, :func:`_orm.attribute_keyed_dict`,
:func:`_orm.column_keyed_dict` so that these dictionary types may be
constructed in place given the data up front; this provides further
compatibility with tools such as Python dataclasses ``.asdict()`` which
relies upon invoking these classes directly as ordinary dictionary classes.

Fixes: #9418
Fixes: #9424
Change-Id: Ib16c4e690b7ac3fcc34df2f139cad61c6c4b2b19

2 years agoMerge "Fixed bug where :meth:`_engine.Row`s could not be unpickled by other processes...
mike bayer [Sun, 5 Mar 2023 20:33:46 +0000 (20:33 +0000)] 
Merge "Fixed bug where :meth:`_engine.Row`s could not be unpickled by other processes." into main

2 years agoMerge "audition pymssql once more; retire sane_rowcount_returning" into main
mike bayer [Sun, 5 Mar 2023 20:29:27 +0000 (20:29 +0000)] 
Merge "audition pymssql once more; retire sane_rowcount_returning" into main

2 years agoMerge "ensure event handlers called for all do_ping" into main
mike bayer [Sun, 5 Mar 2023 20:23:20 +0000 (20:23 +0000)] 
Merge "ensure event handlers called for all do_ping" into main

2 years agoaudition pymssql once more; retire sane_rowcount_returning
Mike Bayer [Fri, 3 Mar 2023 14:30:58 +0000 (09:30 -0500)] 
audition pymssql once more; retire sane_rowcount_returning

pymssql seems to be maintained again and seems to be working
completely, so let's try re-enabling it.

Fixed issue in the new :class:`.Uuid` datatype which prevented it from
working with the pymssql driver. As pymssql seems to be maintained again,
restored testing support for pymssql.

Tweaked the pymssql dialect to take better advantage of
RETURNING for INSERT statements in order to retrieve last inserted primary
key values, in the same way as occurs for the mssql+pyodbc dialect right
now.

Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now
compatible with the SQLAlchemy ORM's "versioned rows" feature, since
SQLAlchemy now computes rowcount for a RETURNING statement in this specific
case by counting the rows returned, rather than relying upon
``cursor.rowcount``.  In particular, the ORM versioned rows use case
(documented at :ref:`mapper_version_counter`) should now be fully
supported with the SQL Server pyodbc dialect.

Change-Id: I38a0666587212327aecf8f98e86031ab25d1f14d
References: #5321
Fixes: #9414
2 years agoFixed bug where :meth:`_engine.Row`s could not be
Federico Caselli [Sat, 4 Mar 2023 22:33:02 +0000 (23:33 +0100)] 
Fixed bug where :meth:`_engine.Row`s could not be
unpickled by other processes.

Fixes: #9423
Change-Id: Ie496e31158caff5f72e0a9069dddd55f3116e0b8

2 years agoMerge "restore old *args approach for MutableDict.pop()" into main
mike bayer [Sat, 4 Mar 2023 20:42:35 +0000 (20:42 +0000)] 
Merge "restore old *args approach for MutableDict.pop()" into main

2 years agoMerge "Restore connectivity with ancient sqlite" into main
mike bayer [Sat, 4 Mar 2023 20:42:26 +0000 (20:42 +0000)] 
Merge "Restore connectivity with ancient sqlite" into main

2 years agoFix the count example in ORM migration doc (#9421)
Grey Li [Sat, 4 Mar 2023 17:51:50 +0000 (01:51 +0800)] 
Fix the count example in ORM migration doc (#9421)

2 years agoMerge "TextualSelect is ReturnsRowsRole" into main
mike bayer [Sat, 4 Mar 2023 16:32:17 +0000 (16:32 +0000)] 
Merge "TextualSelect is ReturnsRowsRole" into main

2 years agoMerge "Add missing overload to Numeric" into main
mike bayer [Sat, 4 Mar 2023 16:31:18 +0000 (16:31 +0000)] 
Merge "Add missing overload to Numeric" into main

2 years agoRestore connectivity with ancient sqlite
Federico Caselli [Mon, 27 Feb 2023 21:05:08 +0000 (22:05 +0100)] 
Restore connectivity with ancient sqlite

Fixed bug that prevented SQLAlchemy to connect when using a very old
sqlite version (before 3.9) on python 3.8+.

Fixes: #9379
Change-Id: I10ca347398221c952e1a572dc6ef80e491d1f5cf

2 years agoMerge "allow multiparams with scalars" into main
mike bayer [Sat, 4 Mar 2023 16:11:17 +0000 (16:11 +0000)] 
Merge "allow multiparams with scalars" into main

2 years agorestore old *args approach for MutableDict.pop()
Nils Philippsen [Tue, 28 Feb 2023 21:04:54 +0000 (16:04 -0500)] 
restore old *args approach for MutableDict.pop()

The typing change in ba0e508141206efc55cdab91df21c1
changed the semantics of pop() and possibly setdefault() in order to
try working at runtime with a two-argument signature.  however
the implementation for this in cpython likely uses a strict `*args`
approach where the lack of the second parameter is explicit, rather
than matching to a constant.  Restore the old implementation inside
of a "not TYPE_CHECKING" block while keeping the type annotated forms
intact for typing only.

Fixed regression caused by typing added to ``sqlalchemy.ext.mutable`` for
:ticket:`8667`, where the semantics of the ``.pop()`` method changed such
that the method was non-working.  Pull request courtesy Nils Philippsen.

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

Change-Id: I213e52f51a795801aacf05307e38cc8c89b54e12

2 years agoMerge "Validate metadata schema arg" into main
mike bayer [Sat, 4 Mar 2023 16:06:50 +0000 (16:06 +0000)] 
Merge "Validate metadata schema arg" into main

2 years agoensure event handlers called for all do_ping
Mike Bayer [Fri, 24 Feb 2023 21:15:21 +0000 (16:15 -0500)] 
ensure event handlers called for all do_ping

The support for pool ping listeners to receive exception events via the
:meth:`.ConnectionEvents.handle_error` event added in 2.0.0b1 for
:ticket:`5648` failed to take into account dialect-specific ping routines
such as that of MySQL and PostgreSQL. The dialect feature has been reworked
so that all dialects participate within event handling.   Additionally,
a new boolean element :attr:`.ExceptionContext.is_pre_ping` is added
which identifies if this operation is occurring within the pre-ping
operation.

For this release, third party dialects which implement a custom
:meth:`_engine.Dialect.do_ping` method can opt in to the newly improved
behavior by having their method no longer catch exceptions or check
exceptions for "is_disconnect", instead just propagating all exceptions
outwards. Checking the exception for "is_disconnect" is now done by an
enclosing method on the default dialect, which ensures that the event hook
is invoked for all exception scenarios before testing the exception as a
"disconnect" exception. If an existing ``do_ping()`` method continues to
catch exceptions and check "is_disconnect", it will continue to work as it
did previously, but ``handle_error`` hooks will not have access to the
exception if it isn't propagated outwards.

Fixes: #5648
Change-Id: I6535d5cb389e1a761aad8c37cfeb332c548b876d

2 years agoRemove duplicate word in tutorial (#9420)
Viicos [Fri, 3 Mar 2023 21:46:49 +0000 (22:46 +0100)] 
Remove duplicate word in tutorial (#9420)

2 years agoAdd missing overload to Numeric
Federico Caselli [Tue, 28 Feb 2023 21:44:27 +0000 (22:44 +0100)] 
Add missing overload to Numeric

Added missing init overload to :class:`_sql.Numeric` to allow
type checkers to properly resolve the type var given the
``asdecimal`` parameter.

this fortunately fixes a glitch in the generate_sql_functions script
also

Fixes: #9391
Change-Id: I9cecc40c52711489e9dbe663f110c3b81c7285e4

2 years agoTextualSelect is ReturnsRowsRole
Mike Bayer [Wed, 1 Mar 2023 16:07:25 +0000 (11:07 -0500)] 
TextualSelect is ReturnsRowsRole

Fixed typing bug where :meth:`_sql.Select.from_statement` would not accept
:func:`_sql.text` or :class:`.TextualSelect` objects as a valid type.
Additionally repaired the :class:`.TextClause.columns` method to have a
return type, which was missing.

Fixes: #9398
Change-Id: I627fc33bf83365e1c7f7c6ed29ea387dfd4a57d8

2 years agoallow multiparams with scalars
Mike Bayer [Thu, 2 Mar 2023 01:44:49 +0000 (20:44 -0500)] 
allow multiparams with scalars

Fixed bug where the :meth:`_engine.Connection.scalars` method was not typed
as allowing a multiple-parameters list, which is now supported using
insertmanyvalues operations.

Change-Id: I65e22c3bee80fc226d484ff1424421dd78520fa5

2 years agoFixed issue when copying ExcludeConstraint
Federico Caselli [Wed, 1 Mar 2023 22:22:46 +0000 (23:22 +0100)] 
Fixed issue when copying ExcludeConstraint

Fixes: #9401
Change-Id: Ie10192348749567110f53ae618fc724f37d1a6a1

2 years agoFix Typo In Tutorial (#9399)
easy_markie_tee [Wed, 1 Mar 2023 21:51:43 +0000 (16:51 -0500)] 
Fix Typo In Tutorial (#9399)

Missing a word on the page `Working with Database Metadata`.
First paragraph under section 'Setting up MetaData with Table objects'.
"...the database which we query from is know [as] a table."

Co-authored-by: markie tee <cassette.head@gmail.com>
2 years agoValidate metadata schema arg
Federico Caselli [Tue, 28 Feb 2023 22:14:05 +0000 (23:14 +0100)] 
Validate metadata schema arg

Validate that when provided the :paramref:`_sql.MetaData.schema`
argument of :class:`_sql.MetaData` is a string.

Change-Id: I4237232d2ee0f5a4d0b9dbd9af5f5b57abf395b4

2 years agoMerge "Restore export for nullslast/nullfirst" into main
mike bayer [Wed, 1 Mar 2023 02:06:23 +0000 (02:06 +0000)] 
Merge "Restore export for nullslast/nullfirst" into main

2 years agoRestore export for nullslast/nullfirst
Federico Caselli [Mon, 27 Feb 2023 21:56:02 +0000 (22:56 +0100)] 
Restore export for nullslast/nullfirst

Previously only the snake case versions nulls_last/nulls_first
were exported in the toplevel namespace.

Fixes: #9390
Change-Id: I9088e858ae108a5c9106b9d8d82655ad605417cc

2 years agoMerge "Improve orm event docs" into main
mike bayer [Tue, 28 Feb 2023 21:57:12 +0000 (21:57 +0000)] 
Merge "Improve orm event docs" into main

2 years agoensure single import per line
Mike Bayer [Tue, 28 Feb 2023 16:05:48 +0000 (11:05 -0500)] 
ensure single import per line

This adds the very small plugin flake8-import-single which
will prevent us from having an import with more than one symbol
on a line.

Flake8 by itself prevents this pattern with E401:

import collections, os, sys

However does not do anything with this:

from sqlalchemy import Column, text

Both statements have the same issues generating merge artifacts
as well as presenting a manual decision to be made.   While
zimports generally cleans up such imports at the top level, we
don't enforce zimports / pre-commit use.

the plugin finds the same issue for imports that are inside of
test methods.   We shouldn't usually have imports in test methods
so most of them here are moved to be top level.

The version is pinned at 0.1.5; the project seems to have no
activity since 2019, however there are three 0.1.6dev releases
on pypi which stopped in September 2019, they seem to be
experiments with packaging.  The source for 0.1.5
is extremely simple and only reveals one method to flake8
(the run() method).

Change-Id: Icea894e43bad9c0b5d4feb5f49c6c666d6ea6aa1

2 years agoImprove orm event docs
Federico Caselli [Fri, 24 Feb 2023 22:24:03 +0000 (23:24 +0100)] 
Improve orm event docs

Change-Id: Ia4f8ce497565c9d5e8df4ef7cc3c3e645f995ff3

2 years agoImprove exclude constraint docs and tests.
Federico Caselli [Mon, 27 Feb 2023 21:47:19 +0000 (22:47 +0100)] 
Improve exclude constraint docs and tests.

Follow up of 71693c94d52612a5e88128575ff308ee4a923c00

Change-Id: Icc9d9942bda92171581dec82cf0cacbd3e3e4162

2 years agoMerge "Add separate version notes for scalars" into main
mike bayer [Mon, 27 Feb 2023 19:13:23 +0000 (19:13 +0000)] 
Merge "Add separate version notes for scalars" into main