diff options
author | CaselIT <cfederico87@gmail.com> | 2023-02-04 13:28:42 +0100 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-02-26 10:33:29 -0500 |
commit | 5c71fd120af824d289cf72dd4b5679a4f839a1eb (patch) | |
tree | b373439e832f57841c9f0611232e8524aca70b2d /tests/test_postgresql.py | |
parent | cbc13309a154dd59ae428f14fa2e7340a5fcb6fc (diff) | |
download | alembic-5c71fd120af824d289cf72dd4b5679a4f839a1eb.tar.gz |
Improved support for expression indexes
Added support for autogenerate comparison of indexes on PostgreSQL which
include SQL expressions; the previous warning that such indexes were
skipped is now removed. This functionality requires SQLAlchemy 2.0.
For older SQLAlchemy versions, these indexes are still skipped.
Fixed issue where indexes on SQLite which include SQL expressions would not
compare against themselves correctly, generating false positives.
SQLAlchemy as of version 2 has no support for reflecting expression based
indexes on SQLite; so for now, the behavior is that SQLite expression-based
indexes are ignored for autogenerate compare, in the same way that
PostgreSQL expression-based indexes were ignored for the time that
SQLAlchemy did not support reflection of such indexes (which is now
supported in SQLAlchemy 2.0 as well as this release of Alembic).
Fixed issue in index detection where autogenerate change detection would
consider indexes with the same columns but with different order as equal,
while in general they are not equivalent in how a database will use them.
Fixes: #1165
Fixes: #1166
Change-Id: I226408eed855b923172e5df0bdab005ed2cc9f53
Diffstat (limited to 'tests/test_postgresql.py')
-rw-r--r-- | tests/test_postgresql.py | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index 6a67e0b..c9860c2 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -39,7 +39,6 @@ from alembic.migration import MigrationContext from alembic.operations import ops from alembic.script import ScriptDirectory from alembic.testing import assert_raises_message -from alembic.testing import assertions from alembic.testing import combinations from alembic.testing import config from alembic.testing import eq_ @@ -1305,64 +1304,3 @@ class PGUniqueIndexAutogenerateTest(AutogenFixtureTest, TestBase): eq_(diffs[0][0], "remove_constraint") eq_(diffs[0][1].name, "uq_name") eq_(len(diffs), 1) - - def _functional_index_warn(self): - return (r"Skip.*refl",) - - def test_functional_ix_one(self): - m1 = MetaData() - m2 = MetaData() - - t1 = Table( - "foo", - m1, - Column("id", Integer, primary_key=True), - Column("email", String(50)), - ) - Index("email_idx", func.lower(t1.c.email), unique=True) - - t2 = Table( - "foo", - m2, - Column("id", Integer, primary_key=True), - Column("email", String(50)), - ) - Index("email_idx", func.lower(t2.c.email), unique=True) - - with assertions.expect_warnings(*self._functional_index_warn()): - diffs = self._fixture(m1, m2) - eq_(diffs, []) - - def test_functional_ix_two(self): - m1 = MetaData() - m2 = MetaData() - - t1 = Table( - "foo", - m1, - Column("id", Integer, primary_key=True), - Column("email", String(50)), - Column("name", String(50)), - ) - Index( - "email_idx", - func.coalesce(t1.c.email, t1.c.name).desc(), - unique=True, - ) - - t2 = Table( - "foo", - m2, - Column("id", Integer, primary_key=True), - Column("email", String(50)), - Column("name", String(50)), - ) - Index( - "email_idx", - func.coalesce(t2.c.email, t2.c.name).desc(), - unique=True, - ) - - with assertions.expect_warnings(*self._functional_index_warn()): - diffs = self._fixture(m1, m2) - eq_(diffs, []) |