summaryrefslogtreecommitdiff
path: root/tests/test_autogen_diffs.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-12-05 15:02:20 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-12-05 15:02:20 -0500
commit98a0e3fb28f9f5dea6242ecd3b1062abc49914af (patch)
treeb0e846a38b1f05af79455a679ad24770dbbb1cf6 /tests/test_autogen_diffs.py
parente5e43c65916670abd9f90b57df5598a308d37d45 (diff)
downloadalembic-98a0e3fb28f9f5dea6242ecd3b1062abc49914af.tar.gz
- Added a type-level comparator that distinguishes :class:`.Integer`,
:class:`.BigInteger`, and :class:`.SmallInteger` types and dialect-specific types; these all have "Integer" affinity so previously all compared as the same. fixes #341
Diffstat (limited to 'tests/test_autogen_diffs.py')
-rw-r--r--tests/test_autogen_diffs.py50
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/test_autogen_diffs.py b/tests/test_autogen_diffs.py
index 690f477..6887058 100644
--- a/tests/test_autogen_diffs.py
+++ b/tests/test_autogen_diffs.py
@@ -3,7 +3,8 @@ import sys
from sqlalchemy import MetaData, Column, Table, Integer, String, Text, \
Numeric, CHAR, ForeignKey, INTEGER, Index, UniqueConstraint, \
TypeDecorator, CheckConstraint, text, PrimaryKeyConstraint, \
- ForeignKeyConstraint
+ ForeignKeyConstraint, VARCHAR, DECIMAL, DateTime, BigInteger, BIGINT, \
+ SmallInteger
from sqlalchemy.types import NULLTYPE
from sqlalchemy.engine.reflection import Inspector
@@ -554,6 +555,53 @@ class AutogenerateDiffTestWSchema(ModelOne, AutogenTest, TestBase):
eq_(diffs[10][3].name, 'pw')
+class CompareTypeSpecificityTest(TestBase):
+ def _fixture(self):
+ from alembic.ddl import impl
+ from sqlalchemy.engine import default
+
+ return impl.DefaultImpl(
+ default.DefaultDialect(), None, False, True, None, {})
+
+ def test_string(self):
+ t1 = String(30)
+ t2 = String(40)
+ t3 = VARCHAR(30)
+ t4 = Integer
+
+ impl = self._fixture()
+ is_(impl.compare_type(Column('x', t3), Column('x', t1)), False)
+ is_(impl.compare_type(Column('x', t3), Column('x', t2)), True)
+ is_(impl.compare_type(Column('x', t3), Column('x', t4)), True)
+
+ def test_numeric(self):
+ t1 = Numeric(10, 5)
+ t2 = Numeric(12, 5)
+ t3 = DECIMAL(10, 5)
+ t4 = DateTime
+
+ impl = self._fixture()
+ is_(impl.compare_type(Column('x', t3), Column('x', t1)), False)
+ is_(impl.compare_type(Column('x', t3), Column('x', t2)), True)
+ is_(impl.compare_type(Column('x', t3), Column('x', t4)), True)
+
+ def test_integer(self):
+ t1 = Integer()
+ t2 = SmallInteger()
+ t3 = BIGINT()
+ t4 = String()
+ t5 = INTEGER()
+ t6 = BigInteger()
+
+ impl = self._fixture()
+ is_(impl.compare_type(Column('x', t5), Column('x', t1)), False)
+ is_(impl.compare_type(Column('x', t3), Column('x', t1)), True)
+ is_(impl.compare_type(Column('x', t3), Column('x', t6)), False)
+ is_(impl.compare_type(Column('x', t3), Column('x', t2)), True)
+ is_(impl.compare_type(Column('x', t5), Column('x', t2)), True)
+ is_(impl.compare_type(Column('x', t1), Column('x', t4)), True)
+
+
class AutogenerateCustomCompareTypeTest(AutogenTest, TestBase):
__only_on__ = 'sqlite'