]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
-adjust the fix for [ticket:2065] to not rely upon type affinity, revert
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Feb 2011 02:05:24 +0000 (21:05 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Feb 2011 02:05:24 +0000 (21:05 -0500)
the _type_affinity attribute of SmallInteger, BigInteger

lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/types.py

index 8bc95ef482e18761c85a2bea73f337f2ab813cd1..b6a6357b5f59cf768bcbdb82226ce460a0192a3a 100644 (file)
@@ -505,10 +505,10 @@ class PGCompiler(compiler.SQLCompiler):
 class PGDDLCompiler(compiler.DDLCompiler):
     def get_column_specification(self, column, **kwargs):
         colspec = self.preparer.format_column(column)
-        type_affinity = column.type._type_affinity
+        impl_type = column.type.dialect_impl(self.dialect)
         if column.primary_key and \
             column is column.table._autoincrement_column and \
-            not issubclass(type_affinity, sqltypes.SmallInteger) and \
+            not isinstance(impl_type, sqltypes.SmallInteger) and \
             (
                 column.default is None or 
                 (
@@ -516,7 +516,7 @@ class PGDDLCompiler(compiler.DDLCompiler):
                     column.default.optional
                 )
             ):
-            if issubclass(type_affinity, sqltypes.BigInteger):
+            if isinstance(impl_type, sqltypes.BigInteger):
                 colspec += " BIGSERIAL"
             else:
                 colspec += " SERIAL"
index 71b55f33f9923d15d7ae15b736ce9f5d8141a425..d25fa3070bf24fee2c87a9a4b00230c921b09d80 100644 (file)
@@ -1007,9 +1007,6 @@ class SmallInteger(Integer):
 
     __visit_name__ = 'small_integer'
 
-    @property
-    def _type_affinity(self):
-        return SmallInteger
 
 class BigInteger(Integer):
     """A type for bigger ``int`` integers.
@@ -1021,9 +1018,6 @@ class BigInteger(Integer):
 
     __visit_name__ = 'big_integer'
 
-    @property
-    def _type_affinity(self):
-        return BigInteger
 
 class Numeric(_DateAffinity, TypeEngine):
     """A type for fixed precision numbers.