summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* document argparse limitationMike Bayer2022-04-191-0/+1
| | | | | Change-Id: I30257b346c3e3b518d63a80e495d354103063fa9 Fixes: #1020
* bump black to 22.3.0Mike Bayer2022-03-282-2/+2
| | | | | | | | | 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 Change-Id: Icb9d98d6473aa603aa29ad1c2d1e43ff3b371db5
* add covering index tests; generalize autogen index testsMike Bayer2022-03-163-569/+631
| | | | | | | | | | | | In response to #1006, add tests for covering indexes for PostgreSQL and MSSQL. Refactor test_autogen_indexes to be generalized for all backends. Parts of this test module should eventually move to the suite tests. Fixes: #1006 Change-Id: I126b0bcbf4f065e5b148567929fece898e66821e
* Fix duplicated constraints when using expressionsNicolas CANIART2022-03-141-0/+21
| | | | | | | | | | | | | | | 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
* fix failing test on windows after sqlite switched to queuepool by defaultCaselIT2022-03-022-17/+12
| | | | Change-Id: Iec2b2ae9c2df9592988fa2239b768d1919eec297
* fix connection handling in consumption testMike Bayer2022-02-111-18/+25
| | | | | | | | | | these tests were leaving connections opened. This rev is necessary for tests to pass assuming QueuePool for SQLite file connections, in I5f6c259def0ef43d401c6163dc99f651e519148d Change-Id: I5f6c259def0ef43d401c6163dc99f651e519148d
* Prevent alter_column() from changing nullabilityGord Thompson2022-02-043-36/+139
| | | | | | | | | | | | | 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. Fixes: #977 Change-Id: Ifbaa06bf149ba39d1a5deb43a6fd42c9ca118894
* resolve for variant before testing for schema typeMike Bayer2022-02-011-0/+24
| | | | | | | | | | | | | | | | | 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
* Provide useful error message in stub testsCaselIT2021-12-311-4/+17
| | | | Change-Id: I6d2662cb5c13d5438210aa001cbdb8c7eb876bb7
* Remove usage of no longer needed compat codeCaselIT2021-11-231-4/+3
| | | | Change-Id: I3180931673496260614e69e95f7da09d68b51714
* Merge "Add new ensure_version command" into mainmike bayer2021-11-181-0/+35
|\
| * Add new ensure_version commandKai Mueller2021-11-181-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. Fixes: #964 Closes: #965 Pull-request: https://github.com/sqlalchemy/alembic/pull/965 Pull-request-sha: a85d2ac048c666126e583fbda482eeabd9c58c53 Change-Id: Ia39d43287634915537725e779dba7ac34f2946e4
* | add type synonym for mysql.LONGTEXT / JSONMike Bayer2021-11-142-2/+54
|/ | | | | | | | | 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. Change-Id: Ia8370d2269c4decea00aa94beafd3d9d861a1269 Fixes: #968
* sqlalchemy 2.0 test updatesMike Bayer2021-11-052-33/+51
| | | | | | | | | - disable branched connection tests for 2.x - dont use future flag for 2.x - adjust batch tests for autobegin, inconsistent SQLite transactional DDL behaviors Change-Id: I70caf6afecc83f880dc92fa6cbc29e2043c43bb9
* dont hardcode transaction opened messagingMike Bayer2021-11-041-3/+3
| | | | | | | Adjustments to the test suite to accommodate for error message changes occurring as of SQLAlchemy 1.4.27. Change-Id: I5092c8d3ba3d16819b200f1dfc3c30b8d24abe30
* Adjust test requirements for mssqlGord Thompson2021-10-231-2/+14
| | | | | | | SQLAlchemy added FK onupdate/ondelete reflection in 1.4.26 Change-Id: Ie4e95294fe3857ea1f28a67a7a78ca9213e8e8f8
* Merge "frame a transaction around autocommit"mike bayer2021-10-051-0/+5
|\
| * frame a transaction around autocommitMike Bayer2021-10-041-0/+5
| | | | | | | | | | | | | | | | | | Fixed issue where the :meth:`.MigrationContext.autocommit_block` feature would fail to function when using a SQLAlchemy engine using 2.0 future mode. Change-Id: I851573424c7cde2595ae22c816ec6580d7cab248 Fixes: #944
* | Fix write hook issue in python < 3.9.Federico Caselli2021-09-301-7/+15
|/ | | | | | | Adjust require of importlib_metadata also include py3.8. Fixes: #934 Change-Id: Id64163a0dc53226d62795d40190b6cec0aee522b
* check all directives in batch block until recreate selectedMike Bayer2021-08-301-6/+39
| | | | | | | | | | | | Fixed regression in batch mode due to :ticket:`883` where the "auto" mode of batch would fail to accommodate any additional migration directives beyond encountering an ``add_column()`` directive, due to a mis-application of the conditional logic that was added as part of this change, leading to "recreate" mode not being used in cases where it is required for SQLite such as for unique constraints. Change-Id: I6315569caff5f3b33d152974ebecc8b18d9cc523 Fixes: #896
* Merge "Add test to ensure method given in #880 works"mike bayer2021-08-251-0/+16
|\
| * Add test to ensure method given in #880 worksMike Bayer2021-08-251-0/+16
| | | | | | | | | | Change-Id: I05dae157320be49eb598084388196e72896bc89d Fixes: #880
* | Merge "remove dependency on pkg_resources"mike bayer2021-08-251-5/+11
|\ \ | |/ |/|
| * remove dependency on pkg_resourcesMike Bayer2021-08-231-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | The dependency on ``pkg_resources`` which is part of ``setuptools`` has been removed, so there is no longer any runtime dependency on ``setuptools``. The functionality has been replaced with ``importlib.metadata`` and ``importlib.resources`` which are both part of Python std.lib, or via pypy dependency ``importlib-metadata`` for Python version < 3.8 and ``importlib-resources`` for Python version < 3.7. Change-Id: I7802fe72ff644f52ae2edde53bc8e16f016b7c45 Fixes: #885
* | Merge "support named CHECK constraints in batch"mike bayer2021-08-242-13/+67
|\ \ | |/ |/|
| * support named CHECK constraints in batchMike Bayer2021-08-242-13/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | avoid importing ForwardRef that's py3.9+ onlyCaselIT2021-08-232-13/+22
| | | | | | | | Change-Id: I76654f10e208d618e21ab0c884cb0abede4d6177
* | Merge "Fix postgresql_include in create_index"mike bayer2021-08-231-0/+13
|\ \
| * | Fix postgresql_include in create_indexSteven Bronson2021-08-231-0/+13
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where usage of the PostgreSQL ``postgresql_include`` option within a :meth:`.Operations.create_index` would raise a KeyError, as the additional column(s) need to be added to the table object used by the construct internally. The issue is equivalent to the SQL Server issue fixed in :ticket:`513`. Pull request courtesy Steven Bronson. Copied from e01041b and 174cb4b. Fixes: #874 Closes: #875 Pull-request: https://github.com/sqlalchemy/alembic/pull/875 Pull-request-sha: 2f9b51890a1296146bcea842dc8bbee53d1d11f5 Change-Id: I68cc2a75dafd3297c5121c5125ff9c463c74f777
* | generate .pyi files for proxied classesMike Bayer2021-08-221-0/+52
|/ | | | | | | | | | | | | | | | | | 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
* Add pep-484 type annotationsCaselIT2021-08-111-18/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* add req for sqlite computed columnsMike Bayer2021-08-101-0/+1
| | | | | | older Python 3.6 has a sqlite that doesn't support this Change-Id: Ie65ef7fabeae2f5142573247548dd50d6d1708dd
* Merge "qualify sqlite batch add column for dynamic defaults"mike bayer2021-08-101-0/+80
|\
| * qualify sqlite batch add column for dynamic defaultsMike Bayer2021-08-101-0/+80
| | | | | | | | | | | | | | | | | | | | Batch "auto" mode will now select for "recreate" if the ``add_column()`` operation is used on SQLite, and the column itself meets the criteria for SQLite where ADD COLUMN is not allowed, in this case a functional or parenthesized SQL expression or a ``Computed`` (i.e. generated) column. Change-Id: Ie948b4b8ad8dc698b458403831e47bac4ad45b8a Fixes: #883
* | Preserve comment and info in Drop/CreateTableOpNicolas CANIART2021-08-101-2/+22
|/ | | | | | | | | | | | | | 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
* Merge "Drop compatibility with python 2.7."mike bayer2021-06-269-77/+55
|\
| * Drop compatibility with python 2.7.CaselIT2021-06-229-77/+55
| | | | | | | | | | | | Now alembic supports only python from version 3.6. Change-Id: Iccf124c2d74af801d90a16c9003cdad318768625
* | Support version_locations paths with spacesGord Thompson2021-06-221-1/+89
|/ | | | | Fixes: #842 Change-Id: Icae7899cecc137eaba26cd14ded9da89df35aae1
* Implement "test suite"Gord Thompson2021-06-1812-2899/+17
| | | | | Fixes: #855 Change-Id: I11386597d9f3a260d7349b58d276b44d78642a6a
* repair py2k supportMike Bayer2021-06-161-4/+6
| | | | | | | | the editor patch had some py3 isms as a result of us disabling the python 2 tests in gerrit. need to move forward w/ the py3k or re-enable py2k Change-Id: If47b0ebc105131fd3e7b8e6d76e0555da1484b8c
* Revendor editor and make dateutil optionalCaselIT2021-06-153-17/+125
| | | | | | | | | | | | | | | | | Re-implemented the ``python-editor`` dependency as a small internal function to avoid the need for external dependencies. The implementation is based on the original version in 7b91b325ff43a0e9235e0f15b57391fa92352626. Make the ``python-dateutil`` library an optional dependency. This library is only required if the ``timezone`` option is used in the Alembic configuration. An extra require named ``tz`` is available with ``pip install alembic[tz]`` to install it. Fixes: #674 Fixes: #856 Change-Id: I07f17b2fea01e3a3d677ce95333fe3e8d8d438fd
* Add kwargs support to DropIndexOp autogenerate renderJet Zhou2021-05-271-0/+17
| | | | | | | | | | | | | | | | | Fixed issue where dialect-specific keyword arguments within the :class:`.DropIndex` operation directive would not render in the autogenerated Python code. As support was improved for adding dialect specific arguments to directives as part of :ticket:`803`, in particular arguments such as "postgresql_concurrently" which apply to the actual create/drop of the index, support was needed for these to render even in a drop index operation. Pull request courtesy Jet Zhou. Fixes: #849 Closes: #852 Pull-request: https://github.com/sqlalchemy/alembic/pull/852 Pull-request-sha: 6392a287179ed746f709ba1e0e07ccab3ea8e4c6 Change-Id: I9b602178c32d6c6a41c0dbe0969a19bd4fa329bd
* differentiate CreateTableOp from model vs. op.create_table()Mike Bayer2021-05-241-0/+30
| | | | | | | | | 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
* Merge "De-duplicate Revision.down_revision helpers."mike bayer2021-05-212-1/+14
|\
| * De-duplicate Revision.down_revision helpers.Simon Bowly2021-05-212-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes an issue when downgrading a revision where dependencies are duplicated (e.g. by specifying the down_revision in depends_on). This causes the down migrations to fail to remove the head, which is caught by an assertion. Added logic to de-duplicate the entries in _normalized_down_revisions and _all_down_revisions without altering revision order. This change revises the previous approach taken in 8d5a9a1b0d32fff5726010afffa48cc0fb738238 to address the problem more generally outside of the topological algorithm. Fixes: #843 Change-Id: I3517fb102b38c783c9a61bfb8dabc02c1fc89c4b
* | Merge "Remove unique/index flags when copying table"mike bayer2021-05-201-3/+42
|\ \ | |/ |/|
| * Remove unique/index flags when copying tableMike Bayer2021-05-201-3/+42
| | | | | | | | | | | | | | | | | | 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
* | ensure heads remain unique in topologicalMike Bayer2021-05-202-0/+33
|/ | | | | | | | Fixed regression where a revision file that contained its own down revision as a dependency would cause an endless loop in the traversal logic. Change-Id: Ie8bd3b4d9f81e4bda131ffdbabe7a90c4a715054 Fixes: #843
* Update black, zimports and flake8CaselIT2021-05-121-5/+5
| | | | Change-Id: Ia7d0ea7cc4389bc6adc4226efd5b18ecb68ffb2b
* Fixed a bug where paths defined in post-write hook optionsCaselIT2021-05-111-2/+44
| | | | | | | would be wrongly escaped in non posix environment (Windows). Fixes: #841 Change-Id: Ife74d9291523378da113c259e3c173a8bc054e47