| Commit message (Collapse) | Author | Age | Files | Lines |
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Fixed typing use of :class:`~sqlalchemy.schema.Column` and other
generic SQLAlchemy classes.
Fixes: #1246
Change-Id: I5ee80395d626894a52e3395c9986213289576355
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
These two API changes were identified as having legacy
use patterns and should be revisited using a deprecation warning
for removal in either 1.12 or 1.13.
Add documentation re: Alembic not using semver, fix
incorrect calling signature example in batch documentation.
Change-Id: I33dc5a8d058bcce77591bb037ae964e626a3387f
Fixes: #1243
Fixes: #1245
|
|
|
|
| |
Change-Id: I5098f9fe2bf57ad93f400e34d914ae0e3b45c747
|
|
|
|
|
|
|
| |
Follow up of I91b453c8848dc5d24d63840bfd7ce4d22dd0e693 to improve some
leftover changes.
Change-Id: I368b93df4d8bd6782b04042ab7872276ff00e56b
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Added :meth:`.Operations.run_async` to the operation module to allow
running async functions in the ``upgrade`` or ``downgrade`` migration
function when running alembic using an async dialect.
This function will receive as first argument an
class:`~sqlalchemy.ext.asyncio.AsyncConnection` sharing the transaction
used in the migration context.
also restore the .execute() method to BatchOperations
Fixes: #1231
Change-Id: I3c3237d570be3c9bd9834e4c61bb3231bfb82765
|
|/
|
|
|
|
|
|
|
|
| |
Argument signatures of Alembic operations now enforce keyword-only
arguments as passed as keyword and not positionally, such as
:paramref:`.Operations.create_table.schema`,
:paramref:`.Operations.add_column.type_`, etc.
Change-Id: I91b453c8848dc5d24d63840bfd7ce4d22dd0e693
Fixes: #1130
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Updated stub generator script to also add stubs method definitions
for the :class:`.Operations` class and the :class:`.BatchOperations`
class obtained from :meth:`.Operations.batch_alter_table`.
Repaired the return signatures for :class:`.Operations` that mostly
return ``None``, and were erroneously referring to ``Optional[Table]``
in many cases.
Fixes: #1093
Change-Id: I98d38dd5a1e719b4dbbc1003746ec28f26c27808
|
|
|
|
|
|
|
|
|
| |
note which constraints are generated from Column (nullable,
single column FOREIGN KEY) and which
are not (PRIMARY KEY, CHECK, UNIQUE, etc.).
Change-Id: I030f2b4e17b08a63e0543567cf01ba03e8752d79
Fixes: #1232
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
### Description
Follow-up / completion of #1220. That change updated a number of docstrings within the codebase to use standardised `black` code formatting, but a couple of locations had been missed.
### Checklist
This pull request is:
- [x] A documentation / typographical error fix
- Good to go, no issue or tests are needed
Closes: #1228
Pull-request: https://github.com/sqlalchemy/alembic/pull/1228
Pull-request-sha: f5696b9ca34998e22af5705434ed2393d86e82c0
Change-Id: I5d935b036d6f4e11eb5c229f9982db587d67ae24
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
### Description
This is a pedantic/consistency follow-up from #1219: that change applied some `black` formatting to two code snippets, and this change applies that formatting to the remaining snippets in the codebase.
For each snippet, I extracted the code and applied formatting using `black` v23.1.0, then placed the results back into the source.
In one case there was an associated 'output' block, and in that case I re-ran the snippet code to update the results of that output too (this included a [change-in-output](https://github.com/sqlalchemy/alembic/compare/main...openculinary:alembic:docstrings/snippet-format-consistency?expand=1#diff-bf4756660cdb31ee8566a2cff72526671356c38a725195723ce0e65e6c11e6cfR124) thanks to a [bugfix since the snippet was written](https://github.com/sqlalchemy/alembic/commit/bc6971aa4abdafb7e1a1123c26a373cc25a34ca9), by the looks of it).
### Checklist
This pull request is:
- [x] A documentation / typographical error fix
Closes: #1220
Pull-request: https://github.com/sqlalchemy/alembic/pull/1220
Pull-request-sha: cd65a453192546a660d6f5ebad5af08bb1c72af4
Change-Id: I6758445633c364c8fb2f4d8376d83607430a36d6
|
|
|
|
|
|
|
|
| |
Correctly pass previously ignored arguments ``insert_before`` and
``insert_after`` in ``batch_alter_column``
Fixes: #1221
Change-Id: I79c9144f3e521fca00a0c32462ae2a69f9f7a032
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
### Description
The `existing_comment` parameter had type `None`, but it should be `Optional[str]`.
Fixes #903
### Checklist
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.
**Have a nice day!**
Closes: #1115
Pull-request: https://github.com/sqlalchemy/alembic/pull/1115
Pull-request-sha: 973ca93b199dccf4474db650bcfee797b2bf7c51
Change-Id: Ic4a25e320fe3e4578e3df9aea689d760844c055e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
### Description
While reading the diff between [`rel_1_10_2...rel_1_10_3`](https://github.com/sqlalchemy/alembic/compare/rel_1_10_2...rel_1_10_3), the introduction of r-strings drew my attention, and that resulted in some [discussion on the relevant commit](https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33).
This changeset filters the production of r-strings during stub-generation to cases where docstrings contain escape (backslash, `\`) characters.
I'll admit that I didn't realize until today that these stubs are primarily for typechecking. Since that's the case, I have doubts about whether the change is worthwhile (consistency and simplicity -- using r-strings for all docstrings in the stubs -- even if it's redundant, seems fine to me).
### Checklist
This pull request is:
- [x] A documentation / typographical error fix
- [x] A short code fix
- Relates to discussion at https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33
Closes: #1218
Pull-request: https://github.com/sqlalchemy/alembic/pull/1218
Pull-request-sha: 352ab8829525435f78838687e12156a3fa3a3d86
Closes: #1219
Pull-request: https://github.com/sqlalchemy/alembic/pull/1219
Change-Id: I2808a592681dabc093d538f589e673fcc5e05822
|
|
|
|
|
|
|
|
|
|
|
| |
Fixed issue where using a directive such as ``op.create_foreign_key()`` to
create a self-referential constraint on a single table where the same
column were present on both sides (e.g. within a composite foreign key)
would produce an error under SQLAlchemy 2.0 and a warning under SQLAlchemy
1.4 indicating that a duplicate column were being added to a table.
Change-Id: I2a8f5d8def2714792bffcdfb8bf88a5080ec8ce7
Fixes: #1215
|
|
|
|
|
|
|
|
|
|
| |
Fixed various typing issues observed with pyright, including issues
involving the combination of :class:`.Function` and
:meth:`.MigrationContext.begin_transaction`.
Fixes: #1191
Fixes: #1201
Change-Id: I9856a8f59c22130c8bbcbed3e19cf2e8a8bf0608
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Take _NONE_NAME into account as a valid constraint name
and don't skip these constraints or consider them to be unnamed.
Thanks to typing this also revealed that previous batch versions
were also keying "_NONE_NAME" constraints as though they were named.
Fixed regression for 1.10.0 where :class:`.Constraint` objects were
suddenly required to have non-None name fields when using batch mode, which
was not previously a requirement.
Change-Id: If4a7191a00848b19cb124bc6da362f3bc6ce1472
Fixes: #1195
|
|
|
|
|
|
|
| |
Index name can be null.
Fixes: #1168
Change-Id: Id7c944e19a9facd7d3862d43f84fd70aedace999
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Update docstring to suggest raw string
When escaping the `:` for `op.execute` if a normal string is used, you need to escape the backslash, eg. `'\\:colon_value'` or using a raw string.
For the docs I feel it is nicer to show the raw string.
* Update stub documentation
Change-Id: Ia605c6c036fe82cebff9b427333404f1c59ea74d
---------
Co-authored-by: CaselIT <cfederico87@gmail.com>
|
|
|
|
| |
Change-Id: I2981335a5deaa798195cfe70f3655d79cd4d8a3b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
command is:
find alembic -name "*.py" | xargs pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format
I'm having some weird fighting with the tools/write_pyi, where
in different runtime contexts it keeps losing "MigrationContext"
and also Callable drops the args, but it's not consisistent.
For whatever reason, under py311 things *do* work every time.
im working w/ clean tox environments so not really sure what the
change is. anyway, let's at least fix the quoting up
around the types.
This is towards getting the "*" in the op signatures for #1130.
Change-Id: I9175905d3b4325e03a97d6752356b70be20e9fad
|
|
|
|
|
|
|
|
|
|
| |
Fixed typing issue where :paramref:`.revision.process_revision_directives`
was not fully typed; additionally ensured all ``Callable`` and ``Dict``
arguments to :meth:`.EnvironmentContext.configure` include parameters in
the typing declaration.
Change-Id: I3ac389992f357359439be5659af33525fc290f96
Fixes: #1110
|
|
|
|
| |
Change-Id: I9fc86c4a92e1b76d19c9e891ff08ce8a46ad4e35
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
**Have a nice day!**
Closes: #1073
Pull-request: https://github.com/sqlalchemy/alembic/pull/1073
Pull-request-sha: 34f0e38e7193a65b659e8af7fff553427048f536
Change-Id: I5f84478e59a74d3d841ff32a0c536e5b32cc9b21
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
Change-Id: I2d040e7e5771eefabba1649d71ed451567c25283
Fixes: #1021
|
|
|
|
|
|
|
|
|
| |
Fixes: #975
Closes: #1032
Pull-request: https://github.com/sqlalchemy/alembic/pull/1032
Pull-request-sha: a111d4f446e861bd01a3cea7ebd1c18a2446601a
Change-Id: Idb8e1c8b6577204a64cde195f094830cdbba68ce
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
Change-Id: Ied84232037aee0b2bf2094b3d3474013d7b41b34
Fixes: #1034
|
|
|
|
| |
Change-Id: I778b63b1c438f31964d841576f0dd54ae1a5fadc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
Fixes: #1004
Closes: #1005
Pull-request: https://github.com/sqlalchemy/alembic/pull/1005
Pull-request-sha: 2fe5c5297bcde990096571a047039c451aa876f6
Change-Id: I2bf48701968fe59a6766f8f8879320b1bfd75774
|
|
|
|
|
|
|
| |
the jenkins pep484 job wasn't catching the tox target
so we missed a mypy failure that got released :/
Change-Id: Ibaee3158971985fb08e43a53f99244bcc4fa0f81
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
also sqla 1.3 needs pytest < 7 to run correctly
Change-Id: I0f5480f97f014e707b8bd4e70f8495d3bd27fd21
Fixes: #982
|
|
|
|
| |
Change-Id: I3180931673496260614e69e95f7da09d68b51714
|
|
|
|
|
|
|
|
|
|
| |
* Update create_check_constraint method typing
* Pass str type down
Fixes: #928
Co-authored-by: Kevin Hwa <liverpoo1026.bne@gmail.com>
Co-authored-by: Kevin Hwa <kevin.hwa@polymathian.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixed type annotations for the "constraint_name" argument of operations
``create_primary_key()``, ``create_foreign_key()``. Pull request courtesy
TilmanK.
Closes: #914
Pull-request: https://github.com/sqlalchemy/alembic/pull/914
Pull-request-sha: 39d44af226b2103da3964daf3229880a0958b97c
Change-Id: Iec4b392c70ae0eeda06dcbfda95a2f044e976686
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixed issue where registration of custom ops was prone to failure due to
the registration process running ``exec()`` on generated code that as of
the 1.7 series includes pep-484 annotations, which in the case of end user
code would result in name resolution errors when the exec occurs. The logic
in question has been altered so that the annotations are rendered as
forward references so that the ``exec()`` can proceed.
Change-Id: I142b89e2f6354b2ce253f3b8109f59fa3aae68ef
Fixes: #920
|
|
|
|
| |
Change-Id: If49e0ff00f0b00ed914ddb8979ae49c3a8a10a0e
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Named CHECK constraints are now supported by batch mode, and will
automatically be part of the recreated table assuming they are named. They
also can be explicitly dropped using ``op.drop_constraint()``. For
"unnamed" CHECK constraints, these are still skipped as they cannot be
distinguished from the CHECK constraints that are generated by the
``Boolean`` and ``Enum`` datatypes.
Note that this change may require adjustments to migrations that drop or
rename columns which feature an associated named check constraint, such
that an additional ``op.drop_constraint()`` directive should be added for
that named constraint as there will no longer be an associated column
for it; for the ``Boolean`` and ``Enum`` datatypes, an ``existing_type``
keyword may be passed to ``BatchOperations.drop_constraint`` as well.
Fixes: #884
Change-Id: I3694430f7c9735bcc3b0765893b333cc8e0d1cd3
|
| |
| |
| |
| | |
Change-Id: I76654f10e208d618e21ab0c884cb0abede4d6177
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Stub .pyi files have been added for the "dynamically"
generated Alembic modules ``alembic.op`` and ``alembic.context``, which
include complete function signatures and docstrings, so that the functions
in these namespaces will have both IDE support (vscode, pycharm, etc) as
well as support for typing tools like Mypy. The files themselves are
statically generated from their source functions within the source tree.
Still not available is sphinx autodoc from the .pyi file. so
we might want to further modify this to write into the .py directly.
if we do *that*, we could almost get rid of ModuleClsProxy and
just generate proxying methods fully in op.py. however, this won't work
for the "extending ops" use case.
Change-Id: I3f084040de25ed3f8e92a4e9d0bb83d69b78eac6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
pep-484 type annotations have been added throughout the library. This
should be helpful in providing Mypy and IDE support, however there is not
full support for Alembic's dynamically modified "op" namespace as of yet; a
future release will likely modify the approach used for importing this
namespace to be better compatible with pep-484 capabilities.
Type originally created using MonkeyType
Add types extracted with the MonkeyType https://github.com/instagram/MonkeyType
library by running the unit tests using ``monkeytype run -m pytest tests``, then
``monkeytype apply <module>`` (see below for further details).
USed MonkeyType version 20.5 on Python 3.8, since newer version have issues
After applying the types, the new imports are placed in a ``TYPE_CHECKING`` guard
and all type definition of non base types are deferred by using the string notation.
NOTE: since to apply the types MonkeType need to import the module, also the test
ones, the patch below mocks the setup done by pytest so that the tests could be
correctly imported
diff --git a/alembic/testing/__init__.py b/alembic/testing/__init__.py
index bdd1746..b1090c7 100644
Change-Id: Iff93628f4b43c740848871ce077a118db5e75d41
--- a/alembic/testing/__init__.py
+++ b/alembic/testing/__init__.py
@@ -9,6 +9,12 @@ from sqlalchemy.testing.config import combinations
from sqlalchemy.testing.config import fixture
from sqlalchemy.testing.config import requirements as requires
+from sqlalchemy.testing.plugin.pytestplugin import PytestFixtureFunctions
+from sqlalchemy.testing.plugin.plugin_base import _setup_requirements
+
+config._fixture_functions = PytestFixtureFunctions()
+_setup_requirements("tests.requirements:DefaultRequirements")
+
from alembic import util
from .assertions import assert_raises
from .assertions import assert_raises_message
Currently I'm using this branch of the sqlalchemy stubs:
https://github.com/sqlalchemy/sqlalchemy2-stubs/tree/alembic_updates
Change-Id: I8fd0700aab1913f395302626b8b84fea60334abd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixed regression due to :ticket:`803` where the ``.info`` and ``.comment``
attributes of ``Table`` would be lost inside of the :class:`.DropTableOp`
class, which when "reversed" into a :class:`.CreateTableOp` would then have
lost these elements. Pull request courtesy Nicolas CANIART.
Fixes: #879
Closes: #881
Pull-request: https://github.com/sqlalchemy/alembic/pull/881
Pull-request-sha: e509b9e8180085998e32746721eeb9266b9f2145
Change-Id: I84a0680266fcf80f3dc922f3cbc76dabd74eedd3
|
|
|
|
|
|
| |
Now alembic supports only python from version 3.6.
Change-Id: Iccf124c2d74af801d90a16c9003cdad318768625
|
|
|
|
|
|
|
|
|
| |
Fixed regression caused by just fixed :ticket:`844` that scaled back the
filter for ``unique=True/index=True`` too far such that these directives no
longer worked for the ``op.create_table()`` op, this has been fixed.
Change-Id: Idbed889ef4fbb7b3a944d3f4631f1cae53030316
Fixes: #848
|
|
|
|
|
|
|
|
|
| |
Fixed 1.6-series regression where ``UniqueConstraint`` and to a lesser
extent ``Index`` objects would be doubled up in the generated model when
the ``unique=True`` / ``index=True`` flags were used.
Change-Id: Idb21891d66cc8d46b257f53062660ce1d4825fb8
Fixes: #844
|
|
|
|
|
|
|
|
| |
Added missing ``batch_op.create_table_comment()``,
``batch_op.drop_table_comment()`` directives to batch ops.
Change-Id: Ia7779619d150a2fe26abb8a8cc89d147a8432f8c
Fixes: #799
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactored the implementation of :class:`.MigrateOperation` constructs such
as :class:`.CreateIndexOp`, :class:`.CreateTableOp`, etc. so that they no
longer rely upon maintaining a persistent version of each schema object
internally; instead, the state variables of each operation object will be
used to produce the corresponding construct when the operation is invoked.
The rationale is so that environments which make use of
operation-manipulation schemes such as those those discussed in
:ref:`autogen_rewriter` are better supported, allowing end-user code to
manipulate the public attributes of these objects which will then be
expressed in the final output, an example is
``some_create_index_op.kw["postgresql_concurrently"] = True``.
Previously, these objects when generated from autogenerate would typically
hold onto the original, reflected element internally without honoring the
other state variables of each construct, preventing the public API from
working.
Change-Id: Ida2537740325de5c21e9447e930a518093f01bd4
Fixes: #803
|
|
|
|
|
|
|
| |
Adjusted the use of SQLAlchemy's ".copy()" internals to use "._copy()"
for version 1.4.0, as this method is being renamed.
Change-Id: I1e69a1628e408f06b43efbc0cc52fc0ad1e8cbc4
|
|
|
|
| |
Change-Id: I2a1a0c273adc871b12e13d7f913609fe1122dab3
|