]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
more fixes for [ticket:269], added MSMediumBlob type
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Aug 2006 00:49:57 +0000 (00:49 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 Aug 2006 00:49:57 +0000 (00:49 +0000)
lib/sqlalchemy/databases/mysql.py
test/engine/reflection.py

index 14e26438f2b3f35bad41be24a63da66ef6da3552..be704ef2a89e29857fbbf5cbfb67465dd0f662da 100644 (file)
@@ -34,7 +34,7 @@ class MSDecimal(MSNumeric):
     def get_col_spec(self):
         if self.precision is not None and self.length is not None:
             return kw_colspec(self, "DECIMAL(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length})
-class MSDouble(sqltypes.Numeric):
+class MSDouble(MSNumeric):
     def __init__(self, precision=10, length=2, **kw):
         if (precision is None and length is not None) or (precision is not None and length is None):
             raise exceptions.ArgumentError("You must specify both precision and length or omit both altogether.")
@@ -60,28 +60,28 @@ class MSFloat(sqltypes.Float):
             return kw_colspec(self, "FLOAT(%(precision)s)" % {'precision': self.precision})
         else:
             return kw_colspec(self, "FLOAT")
-class MSBigInteger(sqltypes.Integer):
+class MSInteger(sqltypes.Integer):
     def __init__(self, length=None, **kw):
         self.length = length
         self.unsigned = 'unsigned' in kw
         self.zerofill = 'zerofill' in kw
-        super(MSBigInteger, self).__init__()
+        super(MSInteger, self).__init__()
     def get_col_spec(self):
         if self.length is not None:
-            return kw_colspec(self, "BIGINT(%(length)s)" % {'length': self.length})
+            return kw_colspec(self, "INTEGER(%(length)s)" % {'length': self.length})
         else:
-            return kw_colspec(self, "BIGINT")
-class MSInteger(sqltypes.Integer):
+            return kw_colspec(self, "INTEGER")
+class MSBigInteger(MSInteger):
     def __init__(self, length=None, **kw):
         self.length = length
         self.unsigned = 'unsigned' in kw
         self.zerofill = 'zerofill' in kw
-        super(MSInteger, self).__init__()
+        super(MSBigInteger, self).__init__()
     def get_col_spec(self):
         if self.length is not None:
-            return kw_colspec(self, "INTEGER(%(length)s)" % {'length': self.length})
+            return kw_colspec(self, "BIGINT(%(length)s)" % {'length': self.length})
         else:
-            return kw_colspec(self, "INTEGER")
+            return kw_colspec(self, "BIGINT")
 class MSSmallInteger(sqltypes.Smallinteger):
     def __init__(self, length=None, **kw):
         self.length = length
@@ -153,7 +153,12 @@ class MSBinary(sqltypes.Binary):
             return None
         else:
             return buffer(value)
-class MSEnum(sqltypes.String):
+
+class MSMediumBlob(MSBinary):
+    def get_col_spec(self):
+        return "MEDIUMBLOB"
+            
+class MSEnum(MSString):
     def __init__(self, *enums):
         self.__enums_hidden = enums
         length = 0
index da6943d5d42fe8bfb416458dcadead826e12e2df..dd8a52a9a212f820adee2a6b6e0003243f2bdaad 100644 (file)
@@ -103,7 +103,12 @@ class ReflectionTest(PersistTest):
             Column('id', Integer, primary_key=True),
             Column('num1', mysql.MSInteger(unsigned=True)),
             Column('text1', mysql.MSLongText),
-            Column('text2', mysql.MSLongText())
+            Column('text2', mysql.MSLongText()),
+             Column('num2', mysql.MSBigInteger),
+             Column('num3', mysql.MSBigInteger()),
+             Column('num4', mysql.MSDouble),
+             Column('num5', mysql.MSDouble()),
+             Column('enum1', mysql.MSEnum('"black"', '"white"')),
             )
         try:
             table.create(checkfirst=True)
@@ -113,6 +118,11 @@ class ReflectionTest(PersistTest):
             assert t2.c.num1.type.unsigned
             assert isinstance(t2.c.text1.type, mysql.MSLongText)
             assert isinstance(t2.c.text2.type, mysql.MSLongText)
+            assert isinstance(t2.c.num2.type, mysql.MSBigInteger)
+            assert isinstance(t2.c.num3.type, mysql.MSBigInteger)
+            assert isinstance(t2.c.num4.type, mysql.MSDouble)
+            assert isinstance(t2.c.num5.type, mysql.MSDouble)
+            assert isinstance(t2.c.enum1.type, mysql.MSEnum)
             t2.drop()
             t2.create()
         finally: