Simple change to fix (some) type checking with Pyright and friends.
Add missing types to **kw
Simple update to types, consistent with other similar instances already in place.
<!-- 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: somewhere between the first and second options. I don't think it merits an issue or test coverage.
- [ ] 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 [Wed, 13 Jul 2022 14:02:53 +0000 (10:02 -0400)]
build fixes
* hardcode rev ids in test that's sensitive to overlapping
substrings
* turn off nitpicky mode
* fix a few rst keywords
* ensure unreleased files not considered as indexable
Mike Bayer [Tue, 12 Jul 2022 23:36:57 +0000 (19:36 -0400)]
implement SQLite RENAME TABLE w schema syntax
Fixed bug where the SQLite implementation of
:meth:`.Operations.rename_table` would render an explicit schema name for
both the old and new table name, which while is the standard ALTER syntax,
is not accepted by SQLite's syntax which doesn't support a rename across
schemas. In particular, the syntax issue would prevent batch mode from
working for SQLite databases that made use of attached databases (which are
treated as "schemas" in SQLAlchemy).
Mike Bayer [Fri, 1 Jul 2022 13:56:10 +0000 (09:56 -0400)]
fail gracefully for batch_alter_table() called in --sql mode
Added an error raise for the condition where
:meth:`.Operations.batch_alter_table` is used in ``--sql`` mode, where the
operation requires table reflection, as is the case when running against
SQLite without giving it a fixed ``Table`` object. Previously the operation
would fail with an internal error. To get a "move and copy" batch
operation as a SQL script without connecting to a database,
a ``Table`` object should be passed to the
:paramref:`.Operations.batch_alter_table.copy_from` parameter so that
reflection may be skipped.
Michał Górny [Sat, 4 Jun 2022 12:05:44 +0000 (14:05 +0200)]
Remove redundant wheel dep from pyproject.toml (#1047)
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
nathannaveen [Sat, 4 Jun 2022 09:10:22 +0000 (04:10 -0500)]
chore: Set permissions for GitHub actions (#1035)
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.
- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)
Adrien Berchet [Tue, 31 May 2022 12:31:25 +0000 (08:31 -0400)]
Trigger events before and after drop table statements
The ``op.drop_table()`` operation directive will now trigger the
``before_drop()`` and ``after_drop()`` DDL event hooks at the table level,
which is similar to how the ``before_create()`` and ``after_create()``
hooks are triggered by the ``op.create_table()`` directive. Note that as
``op.drop_table()`` accepts only a table name and optional schema name, the
``Table`` object received by the event will not have any information within
it other than the table name and schema name.
Mike Bayer [Tue, 10 May 2022 12:39:57 +0000 (08:39 -0400)]
implement full copy for indexes in batch
Fixed issue in batch mode where CREATE INDEX would not use a new column
name in the case of a column rename.
Indexes were previously being moved to the new table without any
steps to rewrite columns. We now vendor the copy approach
from table.to_metadata so that there's a new index expressed
in terms of the new columns.
Caio Carvalho [Tue, 3 May 2022 17:20:18 +0000 (13:20 -0400)]
Add epoch as an option for file_template
Added new token ``epoch`` to the ``file_template`` option, which will
populate the integer epoch as determined by ``int(create_date.timestamp())``.
Pull request courtesy Caio Carvalho.
CaselIT [Mon, 2 May 2022 20:53:39 +0000 (22:53 +0200)]
Fix downgrade with effective head
Fixed issue where downgrade using a relative revision would
fail in case of multiple branches with a single effectively
head due to interdependencies between revisions.
<!-- Provide a general summary of your proposed changes in the Title field above -->
### Description
When working together with `mypy` we have a problem with the default template.
`mypy` raises errors on all migrations when used with https://mypy.readthedocs.io/en/stable/config_file.html#confval-disallow_untyped_defs
So, there are several options:
1. Remove this flag for `[mypy-db.alembic.*]` in `mypy.ini`. This is not a very good idea, because custom code that might get written in this directory might be not fully typed.
2. Edit our own template. This is what we end up doing right now, but this requires some manual work and many users might miss it
3. Update the source! I think that this is harmless (because only python3.6+ is supported), but allows better type-checking
### Checklist
Openning this as a draft for now. Will fix tests after I can see what is failing in the CI.
Issue is also on its way! 🙂
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)
-->
This pull request is:
- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
- [x] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
Mike Bayer [Mon, 28 Mar 2022 19:50:29 +0000 (15:50 -0400)]
bump black to 22.3.0
both black and click were released in the past
few hours, and black 21.5b1 seems to suddenly
be failing on a missing symbol from click. just
update to the latest
Mike Bayer [Sat, 26 Mar 2022 15:47:29 +0000 (11:47 -0400)]
adapt for column collection being "immutable" or "readonly"
in 2.0 the ColumnCollectionConstraint will use a
"read only" column collection, renamed from "immutable".
Add logic to detect both of these kinds of collections
Nicolas CANIART [Sun, 13 Mar 2022 16:39:40 +0000 (12:39 -0400)]
Fix duplicated constraints when using expressions
Fixed issue where using :meth:`.Operations.create_table` in conjunction
with a :class:`.CheckConstraint` that referred to table-bound
:class:`.Column` objects rather than string expressions would be added to
the parent table twice, resulting in an incorrect DDL sequence. Pull
request courtesy Nicolas CANIART.
Mike Bayer [Wed, 2 Mar 2022 01:56:46 +0000 (20:56 -0500)]
desensitize Oracle to FLOAT/DOUBLE/DOUBLE_PRECISION differences
Oracle Float will come back as DOUBLE_PRECISION
as a result of https://github.com/sqlalchemy/sqlalchemy/issues/5465.
Add some synonyms to prevent changes between these names from resulting
in autogenerate positives.
Mike Bayer [Tue, 15 Feb 2022 14:18:50 +0000 (09:18 -0500)]
repair sharing example
the note re: "we dont have to guess" is wrong.
engine_from_config() returns an engine. It seems
like this example was edited a few times and
was not completely checked (it was me, for sure).
for now just use two separate blocks to eliminate
any problems
Gord Thompson [Thu, 13 Jan 2022 18:46:46 +0000 (11:46 -0700)]
Prevent alter_column() from changing nullability
Fixed bug where an alter_column() operation would change a "NOT NULL"
column to "NULL" by emitting an ALTER COLUMN statement that did not specify
"NOT NULL". (In the absence of "NOT NULL" T-SQL was implicitly assuming
"NULL"). An alter_column() operation that specifies `type_=` should also
specify either `nullable=` or `existing_nullable=` to inform Alembic as to
whether the emitted DDL should include "NULL" or "NOT NULL"; a warning is
now emitted if this is missing under this scenario.
Mike Bayer [Fri, 4 Feb 2022 16:51:30 +0000 (11:51 -0500)]
clarify default configuration behavior
alembic does not by default read other sections
besides ``[alembic]``, however the generated ``env.py``
file by default contains instructions to also read logging
directives. clarify that if the configuration file is
customized to not have logging directives, env.py also
needs to be customized.
Mike Bayer [Tue, 1 Feb 2022 14:12:17 +0000 (09:12 -0500)]
resolve for variant before testing for schema type
Fixed regression where usage of a ``with_variant()`` datatype in
conjunction with the ``existing_type`` option of ``op.alter_column()``
under batch mode would lead to an internal exception.
note this exception would only occur under 1.x, under 2.0
the new variant architecture would have prevented this problem,
however it is best here that the ultimate variant type is
unwrapped in the case that we have a plain type with a
schema type as a variant.
Kai Mueller [Wed, 10 Nov 2021 16:38:11 +0000 (11:38 -0500)]
Add new ensure_version command
Add a new command ``alembic ensure_version``, which will ensure that the
Alembic version table is present in the target database, but does not
alter its contents. Pull request courtesy Kai Mueller.
Mike Bayer [Tue, 16 Nov 2021 19:10:58 +0000 (14:10 -0500)]
support 2.0 style variants
Implemented support for recognizing and rendering SQLAlchemy "variant"
types going forward into SQLAlchemy 2.0, where the architecture of
"variant" datatypes will be changing.
Specifically any TypeEngine can now have "variants" by looking
in the _variant_mapping dictionary collection associated with the
type directly.
Mike Bayer [Sat, 13 Nov 2021 15:27:30 +0000 (10:27 -0500)]
add type synonym for mysql.LONGTEXT / JSON
Added a rule to the MySQL impl so that the translation between JSON /
LONGTEXT is accommodated by autogenerate, treating LONGTEXT from the server
as equivalent to an existing JSON in the model.
Mike Bayer [Fri, 5 Nov 2021 15:24:23 +0000 (11:24 -0400)]
sqlalchemy 2.0 test updates
- disable branched connection tests for 2.x
- dont use future flag for 2.x
- adjust batch tests for autobegin, inconsistent
SQLite transactional DDL behaviors
Gord Thompson [Sat, 23 Oct 2021 17:24:40 +0000 (11:24 -0600)]
Remove code to force ENABLE_ASYNCIO to False
Forcing ENABLE_ASYNCIO to False was interfering
with testing under async drivers when the
(third-party dialect) test suite included both
SQLAlchemy and Alembic tests.
Mike Bayer [Sat, 23 Oct 2021 19:58:37 +0000 (15:58 -0400)]
ensure connection is not None
the inspect() API changed in
https://github.com/sqlalchemy/sqlalchemy2-stubs/commit/68f8417888456588714fcced1c6799f3eb00ff2d
to be more accurate which correctly appears to necessitate a
type check in Alembic AutogenContext.inspector() to ensure
"self.connection" isn't None