]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- add test for dialect/impl-specific affinity comparison, #5
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 29 Nov 2011 17:43:20 +0000 (12:43 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 29 Nov 2011 17:43:20 +0000 (12:43 -0500)
tests/test_autogenerate.py

index 7e4336657af747e418564e2493fc9cbf6771665e..0915fb519ca86490204f5463e6fa7f247ab57b4a 100644 (file)
@@ -1,5 +1,5 @@
 from sqlalchemy import MetaData, Column, Table, Integer, String, Text, \
-    Numeric, CHAR, ForeignKey, DATETIME
+    Numeric, CHAR, ForeignKey, DATETIME, TypeDecorator
 from sqlalchemy.types import NULLTYPE
 from alembic import autogenerate, context
 from unittest import TestCase
@@ -217,6 +217,24 @@ class AutogenerateDiffTest(TestCase):
         )
         assert not diff
 
+    def test_affinity_typedec(self):
+        class MyType(TypeDecorator):
+            impl = CHAR
+
+            def load_dialect_impl(self, dialect):
+                if dialect.name == 'sqlite':
+                    return dialect.type_descriptor(Integer())
+                else:
+                    return dialect.type_descriptor(CHAR(32))
+
+        diff = []
+        autogenerate._compare_type("sometable", "somecol",
+            {"name":"somecol", "type":Integer(), 
+            "nullable":True, "default":None},
+            Column("somecol", MyType()),
+            diff, self.autogen_context
+        )
+        assert not diff
 
 class AutogenRenderTest(TestCase):
     """test individual directives"""