summaryrefslogtreecommitdiff
path: root/tests/test_autogenerate.py
Commit message (Collapse)AuthorAgeFilesLines
* - repair the rendering of add_fk_constraint(), quoting there tooMike Bayer2014-11-301-3/+3
|
* - refactor the FK merge a bitMike Bayer2014-11-301-27/+62
| | | | | | | | | | | | | | | | | | | | - getting at attributes of FKs varies a bit on SQLA versions, so implement an _fk_spec() called for all FK inspection - to enable include_object() filters and allow the FK constraint code to flow like that of indexes/uniques, change the approach so that we deal with an _fk_constraint_sig() object again which contains the real ForeignKeyConstraint() within; we need this anyway for include_object, but also allows us to use the standard "drop_constraint" call for rendering. - enhance tests in test_autogen_fks to support real FK databases like Postgresql, MySQL, add in InnoDB flags and ensure that FKs refer to real primary key constraints for PG support - implement and test include_object() support for FKs - inspectors all have get_foreign_keys(), no need to check - repair the drop_constraint call to quote the "type" and table name correctly, run all constraint drops through drop_constraint() for rendering - fix up schema identifiers for foreign key autogens
* - Merge branch 'add_fk_check' of https://bitbucket.org/akamyshnikova/alembic ↵Mike Bayer2014-11-301-37/+62
|\ | | | | | | | | | | | | | | | | | | | | into pr32 - complete merge, get all tests passing - use 'foreignkey' literal Conflicts: alembic/autogenerate/compare.py tests/test_autogenerate.py
| * Fix failing unittests and update compare_fk methodAnn Kamyshnikova2014-11-251-1/+2
| |
| * Update and add some tests for checking fkAnn Kamyshnikova2014-11-071-20/+32
| | | | | | | | fixes issue #178
* | - add a missing @classmethod decorator...Mike Bayer2014-11-241-0/+1
| |
* | ModelOne now has unique constraints so require thatMike Bayer2014-11-211-0/+2
| |
* | include indexes in batchMike Bayer2014-11-211-2/+2
| |
* | - A change in the ordering when columns and constraints are dropped;Mike Bayer2014-11-211-53/+89
| | | | | | | | | | | | | | autogenerate will now place the "drop constraint" calls *before* the "drop column" calls, so that columns involved in those constraints still exist when the constraint is dropped. fixes #247
* | - add some connection cleanupMike Bayer2014-11-091-1/+4
| |
* | - add tests for batch autogenerateMike Bayer2014-11-071-12/+113
|/
* - Indexes and unique constraints are now included in theMike Bayer2014-11-021-15/+21
| | | | | | | :paramref:`.EnvironmentContext.configure.include_object` hook. Indexes are sent with type ``"index"`` and unique constraints with type ``"unique_constraint"``. fixes #203
* - Added a workaround for SQLAlchemy issue #3023 (fixed in 0.9.5) whereMike Bayer2014-11-021-2/+39
| | | | | | | | a column that's part of an explicit PrimaryKeyConstraint would not have its "nullable" flag set to False, thus producing a false autogenerate. Also added a related correction to MySQL which will correct for MySQL's implicit server default of '0' when a NULL integer column is turned into a primary key column. fixes #199
* - If the "alembic_version" table is present in the target metadata,Mike Bayer2014-10-291-9/+67
| | | | | | | | | | autogenerate will skip this also. Pull request courtesy Dj Gilcrease. fixes #28 - The :paramref:`.EnvironmentContext.configure.version_table` and :paramref:`.EnvironmentContext.configure.version_table_schema` arguments are now honored during the autogenerate process, such that these names will be used as the "skip" names on both the database reflection and target metadata sides. fixes #77
* - more tweaks for server defaults re: comparison, test resultsMike Bayer2014-09-201-10/+8
| | | | | | | | - in particular we've changed the server_default for order.amount to text('0'); SQlite and Postgresql now both report the server default as '0', whereas previously, when we were emitting '0' with the quotes in the CREATE TABLE, SQlite reported it as "'0'" and PG as '0::numeric'.
* - move towards sqlalchemy test base. autogenerate tests so farMike Bayer2014-09-131-43/+27
|
* - finish flake8 on testsMike Bayer2014-09-091-34/+49
|
* - do an autopep8 pass for just about everything otherMike Bayer2014-09-091-114/+129
| | | | than line length
* Alter autogenerate tests to show python3 problem on already existing tables sortFlorian Mounier2014-06-251-1/+15
|
* - This releases' "autogenerate index detection" bug, when a MySQL tableMike Bayer2014-05-021-1/+2
| | | | | | | | | | | | includes an Index with the same name as a column, autogenerate reported it as an "add" even though its not; this is because we ignore reflected indexes of this nature due to MySQL creating them implicitly. Indexes that are named the same as a column are now ignored on MySQL if we see that the backend is reporting that it already exists; this indicates that we can still detect additions of these indexes but not drops, as we cannot distinguish a backend index same-named as the column as one that is user generated or mysql-generated. fixes #202
* - index autogen is a big enough deal to warrant its own test suiteMike Bayer2014-05-021-508/+3
|
* - Fixed bug where the ``include_object()`` filter would not receiveMike Bayer2014-04-301-5/+7
| | | | | | | | the original :class:`.Column` object when evaluating a database-only column to be dropped; the object would not include the parent :class:`.Table` nor other aspects of the column that are important for generating the "downgrade" case where the column is recreated. fixes #200
* The feature that keeps on giving, index/unique constraint autogenerateMike Bayer2014-03-131-15/+135
| | | | | | | | | | | | | detection, has even more fixes, this time to accommodate database dialects that both don't yet report on unique constraints, but the backend does report unique constraints as indexes. The logic Alembic uses to distinguish between "this is an index!" vs. "this is a unique constraint that is also reported as an index!" has now been further enhanced to not produce unwanted migrations when the dialect is observed to not yet implement get_unique_constraints() (e.g. mssql). Note that such a backend will no longer report index drops for unique indexes, as these cannot be distinguished from an unreported unique index. fixes #185
* - Added support for autogenerate covering the use case where :class:`.Table`Mike Bayer2014-01-301-49/+107
| | | | | | | | objects specified in the metadata have an explicit ``schema`` attribute whose name matches that of the connection's default schema (e.g. "public" for Postgresql). Previously, it was assumed that "schema" was ``None`` when it matched the "default" schema, now the comparison adjusts for this. #170
* - changelogMike Bayer2014-01-281-116/+153
| | | | | - reorg tests a bit - add test coverage for "include_schemas" in compare_metadata
* Handle include_* arguments in compare_metadata()Roman Podoliaka2014-01-281-0/+117
| | | | | | | include_object, include_symbol and include_schemas are very useful, when you need to specify what objects you want to be compared. Modify compare_metadata() public API function, so that it takes those arguments into account and pass them to _produce_net_changes().
* - changelog for pullreq 17Mike Bayer2014-01-191-1/+60
| | | | | - unit tests for schema-level unique/index detection - cleanup a bit for the get indexes/uniques if only table present
* - More fixes to index autodetection; indexes created with expressionsMike Bayer2014-01-111-0/+22
| | | | | like DESC or functional indexes will no longer cause AttributeError exceptions when attempting to compare the columns. #164
* - clean out test_autogenerateMike Bayer2013-12-271-888/+246
| | | | | | | - start pinning some tests to 0.9, don't need to pin to 0.7 anymore - Autogenerate for ``op.create_table()`` will not include a ``PrimaryKeyConstraint()`` that has no columns. - don't need a full string test for boolean/check constraint autogen
* - more for #157:Mike Bayer2013-12-271-26/+71
| | | | | | | | | | | | | | | | - the ``op.create_table()`` directive will be auto-generated with the ``UniqueConstraint`` objects inline, but will not double them up with a separate ``create_unique_constraint()`` call, which may have been occurring. Indexes still get rendered as distinct ``op.create_index()`` calls even when the corresponding table was created in the same script. - the inline ``UniqueConstraint`` within ``op.create_table()`` includes all the options like ``deferrable``, ``initially``, etc. Previously these weren't rendering. - fixed the index tests to make sure the connection closes after each test - _render_unique_constraint() and _add_unique_constraint() both call into a common function now - call _alembic_autogenerate_prefix within the add_index/drop_index renders
* - repair the autogen index test which apparently wasn't running for PostgresqlMike Bayer2013-12-201-36/+153
| | | | | | | | | | | due to a hardcoded sqlite_db() - get autogen index test cleaned up, working on Postgresql and MySQL - rework the autogen index/unique constraint logic to consider both sets of objects together, and work up all new rules for deduping, comparison. Add new rules specific to MySQL and SQLite and expand the flexibility surrounding the "dupe unique index/unique constraint" thing to work around MySQL doing it in both directions, handles #157 - add a lot more tests and try to emphasize no false positives
* - Fixed an issue with unique constraint autogenerate detection whereMike Bayer2013-12-111-93/+126
| | | | | | | | | a named ``UniqueConstraint`` on both sides with column changes would render with the "add" operation before the "drop", requiring the user to reverse the order manually. - reorganize the index/unique autogenerate test into individual test cases; ideally the whole test suite would be broken out like this for those big tests
* - make these comparisons handle the indexes in either orderMike Bayer2013-11-171-3/+10
|
* - remember to add the SQLA prefixMike Bayer2013-11-171-2/+2
| | | | - fix the SQLA 0.7 case a bit
* wrap text() around itMike Bayer2013-11-131-2/+2
|
* - support SQLAlchemy ticket 2742 by ensuring that expressions in DDL are ↵Mike Bayer2013-11-131-2/+35
| | | | | | rendered (at least in indexes for now) using literal_binds=True, resolve #155
* - fix the change we did in 56a178d2181c84ab8bf2edbe6fdf8439f4 so that the ↵Mike Bayer2013-10-111-0/+5
| | | | | | | unique constraint/index thing on PG still works - replicate the index test for PG
* - use a "signature" for unique constraints so that we can also check onMike Bayer2013-10-081-0/+11
| | | | non-named unique constraints, e.g. those made by the unique=True flag
* - correct for bad booleans coming from SQLA metadata/reflection for the ↵Mike Bayer2013-10-071-1/+3
| | | | index.unique flag,
* - for newly added tables, run compare_indexes with None for conn_tableMike Bayer2013-10-071-9/+25
| | | | | so that we get those table's indexes added as separate create index steps.
* - refactor autogeneration into its own packageMike Bayer2013-09-081-133/+94
| | | | | | | - remove any implicit naming of unique constraints - only explcitly named constraints are supported by autogenerate - ensure we correctly handle the case where unique reflection raises not implemented - fix some naming conventions, changes to expressions for readability
* - add autogenerate support for indexes and unique constraints,Mike Bayer2013-09-081-49/+317
| | | | courtesy ijl. #107
* use mock from local namespaceMike Bayer2013-09-021-1/+1
|
* Simplified testsMaarten van Schaik2013-08-281-97/+42
|
* Add unittests for custom compare_type functionMaarten van Schaik2013-08-281-1/+120
|
* some u's coming in due to the naming change in 0.9Mike Bayer2013-08-271-5/+5
|
* Added new kw argument to :meth:`.EnvironmentContext.configure`Mike Bayer2013-07-111-15/+86
| | | | | | | | | | ``include_object``. This is a more flexible version of the ``include_symbol`` argument which allows filtering of columns as well as tables from the autogenerate process, and in the future will also work for types, constraints and other constructs. The fully constructed schema object is passed, including its name and type as well as a flag indicating if the object is from the local application metadata or is reflected.
* Added support for options like "name" etc. to be renderedMike Bayer2013-05-161-2/+2
| | | | | within CHECK constraints in autogenerate. Courtesy Sok Ann Yap. #125
* fix test failure regarding pypyMike Bayer2013-05-151-0/+3
|\
| * Fix broken test_include_symbol on PyPyHong Minhee2013-04-111-0/+3
| |