]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
17 months agoupdated typing for self_group()
Mark Wine [Tue, 20 Feb 2024 02:25:20 +0000 (18:25 -0800)] 
updated typing for self_group()

2 years agoMerge "Fixed typing of limit, offset and fetch to allow ``None``." into main
Federico Caselli [Tue, 31 Jan 2023 22:08:07 +0000 (22:08 +0000)] 
Merge "Fixed typing of limit, offset and fetch to allow ``None``." into main

2 years agoMerge "Unify doc typing" into main
Federico Caselli [Tue, 31 Jan 2023 22:01:34 +0000 (22:01 +0000)] 
Merge "Unify doc typing" into main

2 years agoFixed typing of limit, offset and fetch to allow ``None``.
Federico Caselli [Tue, 31 Jan 2023 20:20:26 +0000 (21:20 +0100)] 
Fixed typing of limit, offset and fetch to allow ``None``.

Fixes: #9183
Change-Id: I1ac3e3698034826122ea8a0cdc9f8f55a10ed6c1

2 years agoUnify doc typing
Harry Lees [Tue, 31 Jan 2023 13:38:34 +0000 (08:38 -0500)] 
Unify doc typing

### Description
<!-- Describe your changes in detail -->

Fixes #9168

This PR replaces common occurrences of [PEP 585](https://peps.python.org/pep-0585/) style type annotations with annotations compatible with older versions of Python.

I searched for instances of the following supported types from the PEP and replaced with their legacy typing couterparts.

* tuple # typing.Tuple
* list # typing.List
* dict # typing.Dict
* set # typing.Set
* frozenset # typing.FrozenSet
* type # typing.Type

```
grep -r "list\[.*\]" ./build --exclude-dir="./build/venv/*" --exclude-dir="./build/output/*" --exclude="changelog_[0-9]*\.rst"
```

I excluded changelog files from being altered, I think some of these could be changed if necessary but others are likely to require manual checking as the change may target the new typing style specifically.

For any examples that included imports, I tried to ensure that the correct typing imports were included and properly ordered.

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

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

Closes: #9198
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9198
Pull-request-sha: 05ad4651b57c6275b29433e5e76e166344ba6c4c

Change-Id: I41b93b3dee85f9fe00cfbb3d3eb011212795de29

2 years agosupport NewType in type_annotation_map
Mike Bayer [Mon, 30 Jan 2023 20:12:52 +0000 (15:12 -0500)] 
support NewType in type_annotation_map

Added support for :pep:`484` ``NewType`` to be used in the
:paramref:`_orm.registry.type_annotation_map` as well as within
:class:`.Mapped` constructs. These types will behave in the same way as
custom subclasses of types right now; they must appear explicitly within
the :paramref:`_orm.registry.type_annotation_map` to be mapped.

Within this change, the lookup between decl_api._resolve_type
and TypeEngine._resolve_for_python_type is streamlined to not
inspect the given type multiple times, instead passing
in from decl_api to TypeEngine the already "flattened" version
of a Generic or NewType type.

Fixes: #9175
Change-Id: I227cf84b4b88e4567fa2d1d7da0c05b54e00c562

2 years agoblock asyncmy 0.2.6
Mike Bayer [Tue, 31 Jan 2023 19:12:27 +0000 (14:12 -0500)] 
block asyncmy 0.2.6

The package seems fine but the wheels on the site are bad.

Change-Id: I941eacbad880102788c0f6d285a212fc9178a385
References: https://github.com/long2ice/asyncmy/issues/48

2 years agoMerge "MappedAsDataclass applies @dataclasses.dataclass unconditionally" into main
mike bayer [Tue, 31 Jan 2023 16:23:37 +0000 (16:23 +0000)] 
Merge "MappedAsDataclass applies @dataclasses.dataclass unconditionally" into main

2 years agoconsolidate warning re: selectinload.recursion_depth
Mike Bayer [Tue, 31 Jan 2023 16:04:03 +0000 (11:04 -0500)] 
consolidate warning re: selectinload.recursion_depth

Change-Id: I527c5ba52451cd8a926ddea8e5469b9390cfcb27
References: #9199

2 years agoMerge "add __init__ to DeclarativeBase directly" into main
mike bayer [Tue, 31 Jan 2023 14:46:36 +0000 (14:46 +0000)] 
Merge "add __init__ to DeclarativeBase directly" into main

2 years agoMerge "derive optional for nullable from interior of pep-593 types" into main
mike bayer [Tue, 31 Jan 2023 14:44:36 +0000 (14:44 +0000)] 
Merge "derive optional for nullable from interior of pep-593 types" into main

2 years agoapply of_type error message to load.options() as well
Mike Bayer [Mon, 30 Jan 2023 00:51:39 +0000 (19:51 -0500)] 
apply of_type error message to load.options() as well

Improved the error reporting when linking strategy options from a base
class to another attribute that's off a subclass, where ``of_type()``
should be used. Previously, when :meth:`.Load.options` is used, the message
would lack informative detail that ``of_type()`` should be used, which was
not the case when linking the options directly. The informative detail now
emits even if :meth:`.Load.options` is used.

Fixes: #9182
Change-Id: Ibc14923d0cbca9114316cb7db2b30f091dc28af8

2 years agoMerge "don't count / gather INSERT bind names inside of a CTE" into main
mike bayer [Mon, 30 Jan 2023 22:56:56 +0000 (22:56 +0000)] 
Merge "don't count / gather INSERT bind names inside of a CTE" into main

2 years agodon't count / gather INSERT bind names inside of a CTE
Mike Bayer [Sun, 29 Jan 2023 00:50:25 +0000 (19:50 -0500)] 
don't count / gather INSERT bind names inside of a CTE

Fixed regression related to the implementation for the new
"insertmanyvalues" feature where an internal ``TypeError`` would occur in
arrangements where a :func:`_sql.insert` would be referred towards inside
of another :func:`_sql.insert` via a CTE; made additional repairs for this
use case for positional dialects such as asyncpg when using
"insertmanyvalues".

at the core here is a change to positional insertmanyvalues
where we now get exactly the positions for the "manyvalues" within
the larger list, allowing non-"manyvalues" on the left and right
sides at the same time, not assuming anything about how RETURNING
renders etc., since CTEs are in the mix also.

Fixes: #9173
Change-Id: I5ff071fbef0d92a2d6046b9c4e609bb008438afd

2 years agoMappedAsDataclass applies @dataclasses.dataclass unconditionally
Mike Bayer [Mon, 30 Jan 2023 18:28:42 +0000 (13:28 -0500)] 
MappedAsDataclass applies @dataclasses.dataclass unconditionally

When using the :class:`.MappedAsDataclass` superclass, all classes within
the hierarchy that are subclasses of this class will now be run through the
``@dataclasses.dataclass`` function whether or not they are actually
mapped, so that non-ORM fields declared on non-mapped classes within the
hierarchy will be used when mapped subclasses are turned into dataclasses.
This behavior applies both to intermediary classes mapped with
``__abstract__ = True`` as well as to the user-defined declarative base
itself, assuming :class:`.MappedAsDataclass` is present as a superclass for
these classes.

This allows non-mapped attributes such as ``InitVar`` declarations on
superclasses to be used, without the need to run the
``@dataclasses.dataclass`` decorator explicitly on each non-mapped class.
The new behavior is considered as correct as this is what the :pep:`681`
implementation expects when using a superclass to indicate dataclass
behavior.

Fixes: #9179
Change-Id: Ia01fa9806a27f7c1121bf7eaddf2847cf6dc5313

2 years agofix post-production typo for #9174
Mike Bayer [Mon, 30 Jan 2023 17:23:06 +0000 (12:23 -0500)] 
fix post-production typo for #9174

merged in cae662a6383d3ae8f3673c70c3118ea3a1a1606e with one
typo fix afterwards

Fixes: #9174
Change-Id: I5a525da8a95f40c75da627fed49ce828bd498248

2 years agoRevert "fix post-production typo for #9174"
Mike Bayer [Mon, 30 Jan 2023 17:21:59 +0000 (12:21 -0500)] 
Revert "fix post-production typo for #9174"

This reverts commit 3b60c3f53eab8ee5896b3fde525bcf31d4233658.

some scratch code for isolation levels got pushed :(

2 years agofix post-production typo for #9174
Mike Bayer [Mon, 30 Jan 2023 17:21:02 +0000 (12:21 -0500)] 
fix post-production typo for #9174

merged in cae662a6383d3ae8f3673c70c3118ea3a1a1606e with one
typo fix afterwards

Fixes: #9174
Change-Id: I5a525da8a95f40c75da627fed49ce828bd498248

2 years agoMerge "allow single tables and entities for "of"" into main
mike bayer [Mon, 30 Jan 2023 17:20:39 +0000 (17:20 +0000)] 
Merge "allow single tables and entities for "of"" into main

2 years agouse scalars().one() for count migration
Mike Bayer [Mon, 30 Jan 2023 14:02:33 +0000 (09:02 -0500)] 
use scalars().one() for count migration

so that the typed result is non-optional

Fixes: #9184
Change-Id: I40e655010d08f795f3b835b9327ce50c6ec72135

2 years agoderive optional for nullable from interior of pep-593 types
Mike Bayer [Sun, 29 Jan 2023 15:10:30 +0000 (10:10 -0500)] 
derive optional for nullable from interior of pep-593 types

Improved the ruleset used to interpret :pep:`593` ``Annotated`` types when
used with Annotated Declarative mapping, the inner type will be checked for
"Optional" in all cases which will be added to the criteria by which the
column is set as "nullable" or not; if the type within the ``Annotated``
container is optional (or unioned with ``None``), the column will be
considered nullable if there are no explicit
:paramref:`_orm.mapped_column.nullable` parameters overriding it.

Fixes: #9177
Change-Id: I4b1240da198e35b93006fd90f6cb259c9d2cbf30

2 years agoallow single tables and entities for "of"
Mike Bayer [Sun, 29 Jan 2023 04:41:42 +0000 (23:41 -0500)] 
allow single tables and entities for "of"

Opened up typing on :meth:`.Select.with_for_update.of` to also accept table
and mapped class arguments, as seems to be available for the MySQL dialect.

Fixes: #9174
Change-Id: I15659d7084657564bd5a2aa55ef0e4db51b91247

2 years agoMerge "Place DDLConstraintColumn Role in Mapped" into main
mike bayer [Sat, 28 Jan 2023 22:20:00 +0000 (22:20 +0000)] 
Merge "Place DDLConstraintColumn Role in Mapped" into main

2 years agoreword changelog + credit contributor for #9156
Mike Bayer [Sat, 28 Jan 2023 21:51:02 +0000 (16:51 -0500)] 
reword changelog + credit contributor for #9156

Change-Id: Ib5ab3cedd30ee0b0486c12e7c20b07aa76be1128

2 years agoPlace DDLConstraintColumn Role in Mapped
Mike Bayer [Sat, 28 Jan 2023 19:56:17 +0000 (14:56 -0500)] 
Place DDLConstraintColumn Role in Mapped

Fixed typing issue where :func:`_orm.mapped_column` objects typed as
:class:`_orm.Mapped` wouldn't be accepted in schema constraints such as
:class:`_schema.ForeignKey`, :class:`_schema.UniqueConstraint` or
:class:`_schema.Index`.

Fixes: #9170
Change-Id: I41c76d224a1fa2377de151d2a713ba3f43bd245c

2 years agoadd __init__ to DeclarativeBase directly
Mike Bayer [Sat, 28 Jan 2023 19:37:33 +0000 (14:37 -0500)] 
add __init__ to DeclarativeBase directly

Fixed regression in :class:`.DeclarativeBase` class where the registry's
default constructor would not be applied to the base itself, which is
different from how the previous :func:`_orm.declarative_base` construct
works. This would prevent a mapped class with its own ``__init__()`` method
from calling ``super().__init__()`` in order to access the registry's
default constructor and automatically populate attributes, instead hitting
``object.__init__()`` which would raise a ``TypeError`` on any arguments.

This is a very simple change in code, however explaining it is
very complicated.

Fixes: #9171
Change-Id: I4baecdf671861a8198d835e286fe19a51ecda126

2 years agoMerge "Set correct type annotations for ColumnElement.cast" into main
mike bayer [Sat, 28 Jan 2023 16:09:51 +0000 (16:09 +0000)] 
Merge "Set correct type annotations for ColumnElement.cast" into main

2 years agoCorrect #7664 to include DropSchema
Mike Bayer [Sat, 28 Jan 2023 14:37:50 +0000 (09:37 -0500)] 
Correct #7664 to include DropSchema

Corrected the fix for :ticket:`7664`, released in version 2.0.0, to also
include :class:`.DropSchema` which was inadvertently missed in this fix,
allowing stringification without a dialect. The fixes for both constructs
is backported to the 1.4 series as of 1.4.47.

Fixes: #7664
Change-Id: I509b7500ee496ac1e444ea2096c2a02520167e6d

2 years agoSet correct type annotations for ColumnElement.cast
Yurii Karabas [Sat, 28 Jan 2023 14:27:35 +0000 (09:27 -0500)] 
Set correct type annotations for ColumnElement.cast

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

Fixes: #9156
### Description
<!-- Describe your changes in detail -->

### 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
- [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.

**Have a nice day!**

Closes: #9157
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9157
Pull-request-sha: 321dac184ee0d317296a689d7c8e47bf1464bcce

Change-Id: I99fe759a21de910f34bae3bb919e82cd08969e81

2 years agoMerge "fix regression based on mis-match of set/frozenset" into main
mike bayer [Sat, 28 Jan 2023 04:45:27 +0000 (04:45 +0000)] 
Merge "fix regression based on mis-match of set/frozenset" into main

2 years agofix regression based on mis-match of set/frozenset
Mike Bayer [Fri, 27 Jan 2023 23:15:04 +0000 (18:15 -0500)] 
fix regression based on mis-match of set/frozenset

Fixed regression where ORM models that used joined table inheritance with a
composite foreign key would encounter an internal error in the mapper
internals.

Fixes: #9164
Change-Id: I8fdcdf6d72f3304bee191498d5554555b0ab7855

2 years agoremove redundant wheel dep from pyproject.toml
Michał Górny [Fri, 27 Jan 2023 08:31:01 +0000 (03:31 -0500)] 
remove redundant wheel dep from pyproject.toml

### Description
Remove the redundant `wheel` dependency, as it is added by the backend automatically.  Listing it explicitly in the documentation was a historical mistake and has been fixed since, see: https://github.com/pypa/setuptools/commit/f7d30a9529378cf69054b5176249e5457aaf640a

### Checklist

This pull request is:

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

**Have a nice day!**

Closes: #9153
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9153
Pull-request-sha: 8f2d8991f9c057b2dd1a0ca7017968e6eb35e5c8

Change-Id: I877e56819cd3068d94721a7094880366fb2abc9b

2 years agoVersion 2.0.1 placeholder
Mike Bayer [Thu, 26 Jan 2023 22:58:28 +0000 (17:58 -0500)] 
Version 2.0.1 placeholder

2 years ago- 2.0.0 rel_2_0_0
Mike Bayer [Thu, 26 Jan 2023 22:52:28 +0000 (17:52 -0500)] 
- 2.0.0

2 years agoMerge "add hooks/docs for automap w/ multiple schemas" into main
mike bayer [Thu, 26 Jan 2023 22:51:52 +0000 (22:51 +0000)] 
Merge "add hooks/docs for automap w/ multiple schemas" into main

2 years agoadd hooks/docs for automap w/ multiple schemas
Mike Bayer [Tue, 24 Jan 2023 21:31:01 +0000 (16:31 -0500)] 
add hooks/docs for automap w/ multiple schemas

Added new feature to :class:`.Automap` for autoload of classes across
multiple schemas which may have overlapping names, by providing both a
:paramref:`.Automap.prepare.modulename_for_class` parameter as well as a
new collection :attr:`.AutomapBase.by_module`, which stores a dot-separated
namespace of module names linked to classes.

Fixes: #5145
Change-Id: I735fecaacdfc267f1f901d76c2b3880e48f5969d

2 years agoMerge "2.0 prep" into main
mike bayer [Thu, 26 Jan 2023 21:46:33 +0000 (21:46 +0000)] 
Merge "2.0 prep" into main

2 years ago2.0 prep
Mike Bayer [Thu, 26 Jan 2023 18:55:34 +0000 (13:55 -0500)] 
2.0 prep

still waiting on two more gerrits but this will set things up

Change-Id: I966d4c683972c5b965b8db136509062cc8abfe91

2 years agoadd typing to legacy operators
Mike Bayer [Thu, 26 Jan 2023 13:52:01 +0000 (08:52 -0500)] 
add typing to legacy operators

Added typing to legacy operators such as ``isnot()``, ``notin_()``, etc.
which previously were referencing the newer operators but were not
themselves typed.

Fixes: #9148
Change-Id: I3ad7d75d89ec13c9f45063033ecff69d610c72ca

2 years agoMerge "add Mapped to _ORMColCollectionElement" into main
mike bayer [Thu, 26 Jan 2023 18:39:08 +0000 (18:39 +0000)] 
Merge "add Mapped to _ORMColCollectionElement" into main

2 years agofix link
Mike Bayer [Thu, 26 Jan 2023 16:49:02 +0000 (11:49 -0500)] 
fix link

Change-Id: I422ef943ae603e046f309618ba4191a7ba849537

2 years agoadd Mapped to _ORMColCollectionElement
Mike Bayer [Thu, 26 Jan 2023 14:23:07 +0000 (09:23 -0500)] 
add Mapped to _ORMColCollectionElement

Fixed issue where using the :paramref:`_orm.relationship.remote_side`
and similar parameters, passing an annotated declarative object typed as
:class:`_orm.Mapped`, would not be accepted by the type checker.

Fixes: #9150
Change-Id: I5770c17ee4ad8c54661354da9582ec3c4706ffcc

2 years agoMerge "add context for warnings emitted from configure_mappers(), autoflush()" into...
mike bayer [Thu, 26 Jan 2023 14:05:51 +0000 (14:05 +0000)] 
Merge "add context for warnings emitted from configure_mappers(), autoflush()" into main

2 years agoMerge "fix incorrect use of testing.future()" into main
mike bayer [Thu, 26 Jan 2023 14:05:03 +0000 (14:05 +0000)] 
Merge "fix incorrect use of testing.future()" into main

2 years agofix incorrect use of testing.future()
Mike Bayer [Thu, 26 Jan 2023 01:19:10 +0000 (20:19 -0500)] 
fix incorrect use of testing.future()

this has been emitting a warning probably for a long
time

Change-Id: I44a6766b5e92d14ce6bbb5a90ab52648f877afc2

2 years agoadd set_shard_id() loader option for horizontal shard
Mike Bayer [Tue, 24 Jan 2023 16:05:12 +0000 (11:05 -0500)] 
add set_shard_id() loader option for horizontal shard

Added new option to horizontal sharding API
:class:`_horizontal.set_shard_id` which sets the effective shard identifier
to query against, for both the primary query as well as for all secondary
loaders including relationship eager loaders as well as relationship and
column lazy loaders.

Modernize sharding examples with new-style mappings, add new asyncio example.

Fixes: #7226
Fixes: #7028
Change-Id: Ie69248060c305e8de04f75a529949777944ad511

2 years agoMerge "disable new tox 4.4.0 feature" into main
mike bayer [Wed, 25 Jan 2023 23:32:15 +0000 (23:32 +0000)] 
Merge "disable new tox 4.4.0 feature" into main

2 years agoMerge "Add public protocol for mapped class" into main
mike bayer [Wed, 25 Jan 2023 22:45:31 +0000 (22:45 +0000)] 
Merge "Add public protocol for mapped class" into main

2 years agodisable new tox 4.4.0 feature
Mike Bayer [Wed, 25 Jan 2023 22:34:08 +0000 (17:34 -0500)] 
disable new tox 4.4.0 feature

a new flag constrain_package_deps appears to interpret deps
as constraints, and not requirements.  turn it off.

also remove the python setup command and use their default,
try to stay compatible

Change-Id: Ib400a7783c08c2c63ddb099944cd48b9631acd75

2 years agoImprove examples, make typing beta, remove beta from asyncio
Federico Caselli [Wed, 25 Jan 2023 20:40:04 +0000 (21:40 +0100)] 
Improve examples, make typing beta, remove beta from asyncio

Change-Id: Icbde11dcaae5fa6f5e83cd50b6a301081a3ab962

2 years agoAdd public protocol for mapped class
Federico Caselli [Mon, 23 Jan 2023 21:51:51 +0000 (22:51 +0100)] 
Add public protocol for mapped class

Fixes: #8624
Change-Id: Ia7a66ae9ba534ed7152f95dfd0f7d05b9d00165a

2 years agoadd fwds ports to selected 1.4 issues
Mike Bayer [Wed, 25 Jan 2023 17:32:33 +0000 (12:32 -0500)] 
add fwds ports to selected 1.4 issues

Change-Id: Ic9ffd1e1f15570e366c12bf08374e8313059f288

2 years agoMake comment support conditional on fn_listextendedproperty availability
Mike Bayer [Wed, 25 Jan 2023 13:58:03 +0000 (08:58 -0500)] 
Make comment support conditional on fn_listextendedproperty availability

The newly added comment reflection and rendering capability of the MSSQL
dialect, added in :ticket:`7844`, will now be disabled by default if it
cannot be determined that an unsupported backend such as Azure Synapse may
be in use; this backend does not support table and column comments and does
not support the SQL Server routines in use to generate them as well as to
reflect them. A new parameter ``supports_comments`` is added to the dialect
which defaults to ``None``, indicating that comment support should be
auto-detected. When set to ``True`` or ``False``, the comment support is
either enabled or disabled unconditionally.

Fixes: #9142
Change-Id: Ib5cac31806185e7353e15b3d83b580652d304b3b

2 years agoadd context for warnings emitted from configure_mappers(), autoflush()
jonathan vanasco [Fri, 12 Nov 2021 17:45:54 +0000 (12:45 -0500)] 
add context for warnings emitted from configure_mappers(), autoflush()

Improved the notification of warnings that are emitted within the configure
mappers or flush process, which are often invoked as part of a different
operation, to add additional context to the message that indicates one of
these operations as the source of the warning within operations that may
not be obviously related.

Fixes: #7305
Change-Id: I79da7a6a5d4cf67d57615d0ffc2b8d8454011c84

2 years agoMerge "Type annotations for sqlalchemy.orm.mapped_collection" into main
mike bayer [Tue, 24 Jan 2023 23:04:10 +0000 (23:04 +0000)] 
Merge "Type annotations for sqlalchemy.orm.mapped_collection" into main

2 years agoMerge "fix stringify for CreateSchema" into main
mike bayer [Tue, 24 Jan 2023 22:18:53 +0000 (22:18 +0000)] 
Merge "fix stringify for CreateSchema" into main

2 years agofix stringify for CreateSchema
Mike Bayer [Tue, 24 Jan 2023 20:34:27 +0000 (15:34 -0500)] 
fix stringify for CreateSchema

Fixed stringify for a the :class:`.CreateSchema` DDL construct, which would
fail with an ``AttributeError`` when stringified without a dialect.

Fixes: #7664
Change-Id: Ifc1769604bc5219c060f5112f7bdea0f780f1a1c

2 years agoreflect Oracle ROWID
Mike Bayer [Tue, 24 Jan 2023 20:08:30 +0000 (15:08 -0500)] 
reflect Oracle ROWID

Added :class:`_oracle.ROWID` to reflected types as this type may be used in
a "CREATE TABLE" statement.

Fixes: #5047
Change-Id: I818dcf68ed81419d0fd5df5e2d51d6fa0f1be7fc

2 years agoType annotations for sqlalchemy.orm.mapped_collection
Maksim Latysh [Tue, 24 Jan 2023 16:03:44 +0000 (11:03 -0500)] 
Type annotations for sqlalchemy.orm.mapped_collection

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

### Description
<!-- Describe your changes in detail -->
An attempt to annotate lib/sqlalchemy/orm/mapped_collection.py with type hints (issue https://github.com/sqlalchemy/sqlalchemy/issues/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.
- [ ] 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: #9140
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9140
Pull-request-sha: facb4717134943dd651905f7c72618eb66a9eca5

Change-Id: I0fb80e2ea7ed2247c494487fb6c8d72efb4e9802

2 years agoadd typing issue template
Federico Caselli [Mon, 23 Jan 2023 20:34:25 +0000 (21:34 +0100)] 
add typing issue template

Change-Id: I429bf499274362e53ab3e7ea0f65c0ef5265a14d

2 years agofix up random col name test and ensure no dupes
Mike Bayer [Mon, 23 Jan 2023 20:15:42 +0000 (15:15 -0500)] 
fix up random col name test and ensure no dupes

this is a bit of a goofy test which can occasionally fail,
so add a set to prevent names from being duplicated.

Change-Id: Ie7ac605f517ce31f2c5d092a692d93f733180716

2 years agoMerge "generate stubs for func known functions" into main
mike bayer [Mon, 23 Jan 2023 18:37:07 +0000 (18:37 +0000)] 
Merge "generate stubs for func known functions" into main

2 years agoMerge "Result.__enter__ annotation" into main
mike bayer [Mon, 23 Jan 2023 17:51:11 +0000 (17:51 +0000)] 
Merge "Result.__enter__ annotation" into main

2 years agogenerate stubs for func known functions
Mike Bayer [Fri, 20 Jan 2023 20:17:44 +0000 (15:17 -0500)] 
generate stubs for func known functions

Added typing for the built-in generic functions that are available from the
:data:`_sql.func` namespace, which accept a particular set of arguments and
return a particular type, such as for :class:`_sql.count`,
:class:`_sql.current_timestamp`, etc.

Fixes: #9129
Change-Id: I1a2e0dcca3048c77e84dc786843a7df05c457dfa

2 years agoResult.__enter__ annotation
Martin Baláž [Sun, 22 Jan 2023 16:16:56 +0000 (11:16 -0500)] 
Result.__enter__ annotation

Fixed typing issue where the object type when using :class:`_engine.Result`
as a context manager were not preserved, indicating :class:`_engine.Result`
in all cases rather than the specific :class:`_engine.Result` sub-type.
Pull request courtesy Martin Baláž.

Fixes: #9136
Closes: #9135
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9135
Pull-request-sha: 97a9829db59db359fbb400ec0d913bdf8954f00a

Change-Id: I60a7f89ba39bf0f9fc5e6e7bf09f642167fe476f

2 years agoRun bracket interpretation for reflection
Shan [Sun, 22 Jan 2023 16:19:11 +0000 (11:19 -0500)] 
Run bracket interpretation for reflection

Fixed bug where a schema name given with brackets, but no dots inside the
name, for parameters such as :paramref:`_schema.Table.schema` would not be
interpreted within the context of the SQL Server dialect's documented
behavior of interpreting explicit brackets as token delimiters, first added
in 1.2 for #2626, when referring to the schema name in reflection
operations. The original assumption for #2626's behavior was that the
special interpretation of brackets was only significant if dots were
present, however in practice, the brackets are not included as part of the
identifier name for all SQL rendering operations since these are not valid
characters within regular or delimited identifiers.  Pull request courtesy
Shan.

Fixes: #9133
Closes: #9134
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9134
Pull-request-sha: 5dac87c82cd3063dd8e50f0075c7c00330be6439

Change-Id: I7a507bc38d75a04ffcb7e920298775baae22c6d1

2 years agoclarify __table__, local_table
Mike Bayer [Fri, 20 Jan 2023 18:34:07 +0000 (13:34 -0500)] 
clarify __table__, local_table

These are typed as FromClause, make sure this is stated up front
indicating Table as a subset of possible object types.

Change-Id: I15961a69d3655600249e3cfe6c4b3372f97d4485
References: #9130

2 years agoMerge "typing updates" into main
mike bayer [Fri, 20 Jan 2023 17:03:14 +0000 (17:03 +0000)] 
Merge "typing updates" into main

2 years agotyping updates
Mike Bayer [Thu, 19 Jan 2023 20:34:46 +0000 (15:34 -0500)] 
typing updates

The :meth:`_sql.ColumnOperators.in_` and
:meth:`_sql.ColumnOperators.not_in_` are typed to include
``Iterable[Any]`` rather than ``Sequence[Any]`` for more flexibility in
argument type.

The :func:`_sql.or_` and :func:`_sql.and_` from a typing perspective
require the first argument to be present, however these functions still
accept zero arguments which will emit a deprecation warning at runtime.
Typing is also added to support sending the fixed literal ``False`` for
:func:`_sql.or_` and ``True`` for :func:`_sql.and_` as the first argument
only, however the documentation now indicates sending the
:func:`_sql.false` and :func:`_sql.true` constructs in these cases as a
more explicit approach.

Fixed typing issue where iterating over a :class:`_orm.Query` object
was not correctly typed.

Fixes: #9122
Fixes: #9123
Fixes: #9125
Change-Id: I500e3e1b826717b3dd49afa1e682c3c8279c9226

2 years agoimplement basic typing for lambda elements
Mike Bayer [Thu, 19 Jan 2023 17:09:29 +0000 (12:09 -0500)] 
implement basic typing for lambda elements

These weren't working at all, so fixed things up and
added a test suite.   Keeping things very basic with Any
returns etc. as having more specific return types
starts making it too cumbersome to write end-user code.

Corrected the type passed for "lambda statements" so that a plain lambda is
accepted by mypy, pyright, others without any errors about argument types.
Additionally implemented typing for more of the public API for lambda
statements and ensured :class:`.StatementLambdaElement` is part of the
:class:`.Executable` hierarchy so it's typed as accepted by
:meth:`_engine.Connection.execute`.

Fixes: #9120
Change-Id: Ia7fa34e5b6e43fba02c8f94ccc256f3a68a1f445

2 years agoreword INSERT explanation
Mike Bayer [Thu, 19 Jan 2023 14:43:19 +0000 (09:43 -0500)] 
reword INSERT explanation

Change-Id: I08460f0a77131c8c1406c3496e9d64a5a26bf6ff

2 years agoVersion 2.0.0rc4 placeholder
Mike Bayer [Thu, 19 Jan 2023 00:31:16 +0000 (19:31 -0500)] 
Version 2.0.0rc4 placeholder

2 years ago- 2.0.0rc3 rel_2_0_0rc3
Mike Bayer [Thu, 19 Jan 2023 00:21:39 +0000 (19:21 -0500)] 
- 2.0.0rc3

2 years agoavoid confusion in rst comment
Federico Caselli [Wed, 18 Jan 2023 22:02:36 +0000 (23:02 +0100)] 
avoid confusion in rst comment

Change-Id: I6e971f7445ae19f73097516b58776ab05a5371f1

2 years agoMerge "refactor code generation tools , include --check command" into main
mike bayer [Wed, 18 Jan 2023 21:53:07 +0000 (21:53 +0000)] 
Merge "refactor code generation tools , include --check command" into main

2 years agofix typo, add missing command to unittest pg docker example
Federico Caselli [Wed, 18 Jan 2023 21:28:34 +0000 (22:28 +0100)] 
fix typo, add missing command to unittest pg docker example

Change-Id: Ic640ccf7459c39cb4f6ab8dcfb3efed1a1dbb55f

2 years agorefactor code generation tools , include --check command
Mike Bayer [Wed, 18 Jan 2023 17:45:42 +0000 (12:45 -0500)] 
refactor code generation tools , include --check command

in particular it looks like CI was not picking up on the
"git diff" oriented commands, which were failing to run due
to pathing issues.  As we were setting cwd for black/zimports
relative to sqlalchemy library, and tox installs it in
the venv, black/zimports would fail to run from tox, and
since these are subprocess.run we didn't pick up the
failure.

This overall locks down how zimports/black are run
so that we are definitely from the source root, by using
the location of tools/ to determine the root.

Fixes: #8892
Change-Id: I7c54b747edd5a80e0c699b8456febf66d8b62375

2 years agoRemove redundant 1.x reference (#9115)
Sam Bull [Wed, 18 Jan 2023 19:33:05 +0000 (19:33 +0000)] 
Remove redundant 1.x reference (#9115)

2 years agoBump pypa/cibuildwheel from 2.11.2 to 2.12.0
dependabot[bot] [Wed, 18 Jan 2023 16:39:45 +0000 (11:39 -0500)] 
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.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pypa/cibuildwheel/releases">pypa/cibuildwheel's releases</a>.</em></p>
<blockquote>
<h2>v2.12.0</h2>
<ul>
<li>✨ Adds support for PyPy arm64 wheels. This means that you can build PyPy wheels for Apple Silicon machines. Cross-compilation is not supported for these wheels, so you'll have to build on an Apple Silicon machine. (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1372">#1372</a>)</li>
<li>🛠 Pinned version updates, including PyPy to v7.3.11 and setuptools to 66.0.0.</li>
</ul>
<h2>v2.11.4</h2>
<ul>
<li>🐛 Fix a bug that caused missing wheels on Windows when a test was skipped using CIBW_TEST_SKIP (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1377">#1377</a>)</li>
<li>🛠 Updates CPython 3.11 to 3.11.1 (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1371">#1371</a>)</li>
<li>🛠 Updates PyPy 3.7 to 3.7.10, except on macOS which remains on 7.3.9 due to a bug. (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1371">#1371</a>)</li>
<li>📚 Added a reference to abi3audit to the docs (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1347">#1347</a>)</li>
</ul>
<h2>v2.11.3</h2>
<ul>
<li>✨ Improves the 'build options' log output that's printed at the start of each run (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1352">#1352</a>)</li>
<li>✨ Added a friendly error message to a common misconfiguration of the <code>CIBW_TEST_COMMAND</code> option - not specifying path using the <code>{project}</code> placeholder (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1336">#1336</a>)</li>
<li>🛠 The GitHub Action now uses Powershell on Windows to avoid occasional incompabilities with bash (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1346">#1346</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md">pypa/cibuildwheel's changelog</a>.</em></p>
<blockquote>
<h3>v2.12.0</h3>
<p><em>16 Jan 2023</em></p>
<ul>
<li>✨ Adds support for PyPy arm64 wheels. This means that you can build PyPy wheels for Apple Silicon machines. Cross-compilation is not supported for these wheels, so you'll have to build on an Apple Silicon machine. (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1372">#1372</a>)</li>
<li>🛠 Pinned version updates, including PyPy to v7.3.11 and setuptools to 66.0.0.</li>
</ul>
<h3>v2.11.4</h3>
<p><em>24 Dec 2022</em></p>
<ul>
<li>🐛 Fix a bug that caused missing wheels on Windows when a test was skipped using CIBW_TEST_SKIP (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1377">#1377</a>)</li>
<li>🛠 Updates CPython 3.11 to 3.11.1 (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1371">#1371</a>)</li>
<li>🛠 Updates PyPy to 7.3.10, except on macOS which remains on 7.3.9 due to a bug on that platform. (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1371">#1371</a>)</li>
<li>📚 Added a reference to abi3audit to the docs (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1347">#1347</a>)</li>
</ul>
<h3>v2.11.3</h3>
<p><em>5 Dec 2022</em></p>
<ul>
<li>✨ Improves the 'build options' log output that's printed at the start of each run (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1352">#1352</a>)</li>
<li>✨ Added a friendly error message to a common misconfiguration of the <code>CIBW_TEST_COMMAND</code> option - not specifying path using the <code>{project}</code> placeholder (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1336">#1336</a>)</li>
<li>🛠 The GitHub Action now uses Powershell on Windows to avoid occasional incompabilities with bash (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1346">#1346</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pypa/cibuildwheel/commit/a808017c3962f4d678fe685239668aad8c150932"><code>a808017</code></a> Bump version: v2.12.0</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/4e1fcb8df69a5eef7d82b06b70253846342eb0a0"><code>4e1fcb8</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1394">#1394</a> from pypa/update-dependencies-pr</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/4afa12ed06e8462c24040a41ee170c8983001172"><code>4afa12e</code></a> Update dependencies</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/92cb1d8990e2418c0bd24c5e8d74406345216b58"><code>92cb1d8</code></a> feat: add PyPy macOS arm64 (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1372">#1372</a>)</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/06c4927798c6cc67792db86e6e133df4ac0a7139"><code>06c4927</code></a> [Bot] Update dependencies (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1381">#1381</a>)</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/9b0d63b2f43d06853cbc7eae711646d93983a4e4"><code>9b0d63b</code></a> ci: use normal AppVeyor macOS image (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1388">#1388</a>)</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/6df156807a9b029ed513c6b5c4f4fbe43f7a2c0c"><code>6df1568</code></a> [pre-commit.ci] pre-commit autoupdate (<a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1382">#1382</a>)</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/27fc88e6385a995e61a87ee4b903bed263e6a6e2"><code>27fc88e</code></a> Bump version: v2.11.4</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/a7e9ece1d420cd7a546d12c845f2847aa73f4c43"><code>a7e9ece</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pypa/cibuildwheel/issues/1371">#1371</a> from pypa/update-dependencies-pr</li>
<li><a href="https://github.com/pypa/cibuildwheel/commit/b9a3ed8c6a52c00ac16b94e6039d00e6263b30ca"><code>b9a3ed8</code></a> Update cibuildwheel/resources/build-platforms.toml</li>
<li>Additional commits viewable in <a href="https://github.com/pypa/cibuildwheel/compare/v2.11.2...v2.12.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pypa/cibuildwheel&package-manager=github_actions&previous-version=2.11.2&new-version=2.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

Change-Id: I4d15e4d07d07908fd23bff46ceb6931dee02aa89

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

Closes: #9107
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9107
Pull-request-sha: 5004ecc1d4df39017d97fef5ee91201e41b0cca5

Change-Id: I0a277582132287b71b2d018865934e84db8f8971

2 years agomypy plugin fixes
Mike Bayer [Tue, 17 Jan 2023 01:17:50 +0000 (20:17 -0500)] 
mypy plugin fixes

Adjustments made to the mypy plugin to accommodate for some potential
changes being made for issue #236 sqlalchemy2-stubs when using SQLAlchemy
1.4. These changes are being kept in sync within SQLAlchemy 2.0.
The changes are also backwards compatible with older versions of
sqlalchemy2-stubs.

Fixed crash in mypy plugin which could occur on both 1.4 and 2.0 versions
if a decorator for the :func:`_orm.registry.mapped` decorator were used
that was referenced in an expression with more than two components (e.g.
``@Backend.mapper_registry.mapped``). This scenario is now ignored; when
using the plugin, the decorator expression needs to be two components (i.e.
``@reg.mapped``).

References: https://github.com/sqlalchemy/sqlalchemy2-stubs/issues/236
Fixes: #9102
Change-Id: Ieb1bf7bf8184645bcd43253e57f1c267b2640537

2 years agopass driver_connection to TypeInfo.fetch()
Mike Bayer [Tue, 17 Jan 2023 14:44:05 +0000 (09:44 -0500)] 
pass driver_connection to TypeInfo.fetch()

Fixed regression where psycopg3 changed an API call as of version 3.1.8 to
expect a specific object type that was previously not enforced, breaking
connectivity for the psycopg3 dialect.

Fixes: #9106
Change-Id: Ibb42f84b1086f30173aeb6e1f3256c56d129fe6e

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