summaryrefslogtreecommitdiff
path: root/tests/test_autogen_diffs.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-11-09 08:42:12 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-11-09 08:47:23 -0500
commit01e9b8df995ae5ae404c3973ab0b1a99e9c08dce (patch)
treecd966d5149dde2eb380d9285c02506c1117473b3 /tests/test_autogen_diffs.py
parent539227fcbf4a7d2196c931696e6aa8ae1cad3dbe (diff)
downloadalembic-01e9b8df995ae5ae404c3973ab0b1a99e9c08dce.tar.gz
Compare to metadata_impl in compare_type() to guard against custom TypeDecorator
Fixed bug where usage of a custom TypeDecorator which returns a per-dialect type via :meth:`.TypeDecorator.load_dialect_impl` that differs significantly from the default "impl" for the type decorator would fail to compare correctly during autogenerate. Change-Id: I384df35be9513bf8a2ae55e7daa9a52c23108a49 Fixes: #395
Diffstat (limited to 'tests/test_autogen_diffs.py')
-rw-r--r--tests/test_autogen_diffs.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_autogen_diffs.py b/tests/test_autogen_diffs.py
index 04c9e96..4816134 100644
--- a/tests/test_autogen_diffs.py
+++ b/tests/test_autogen_diffs.py
@@ -5,7 +5,8 @@ from sqlalchemy import MetaData, Column, Table, Integer, String, Text, \
TypeDecorator, CheckConstraint, text, PrimaryKeyConstraint, \
ForeignKeyConstraint, VARCHAR, DECIMAL, DateTime, BigInteger, BIGINT, \
SmallInteger
-from sqlalchemy.types import NULLTYPE
+from sqlalchemy.dialects import sqlite
+from sqlalchemy.types import NULLTYPE, VARBINARY
from sqlalchemy.engine.reflection import Inspector
from alembic.operations import ops
@@ -592,6 +593,26 @@ class CompareTypeSpecificityTest(TestBase):
return impl.DefaultImpl(
default.DefaultDialect(), None, False, True, None, {})
+ def test_typedec_to_nonstandard(self):
+
+ class PasswordType(TypeDecorator):
+ impl = VARBINARY
+
+ def copy(self, **kw):
+ return PasswordType(self.impl.length)
+
+ def load_dialect_impl(self, dialect):
+ if dialect.name == 'default':
+ impl = sqlite.NUMERIC(self.length)
+ else:
+ impl = VARBINARY(self.length)
+ return dialect.type_descriptor(impl)
+
+ impl = self._fixture()
+ impl.compare_type(
+ Column('x', sqlite.NUMERIC(50)),
+ Column('x', PasswordType(50)))
+
def test_string(self):
t1 = String(30)
t2 = String(40)