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`.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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áž.
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.
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.
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`.
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.
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 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`.
<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)
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``).
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.
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.
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
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.
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.
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
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.
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.
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.
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.