]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix mysql reflection of TINYINT(1) UNSIGNED columns.
authorJason Kirtland <jek@discorporate.us>
Wed, 10 Feb 2010 18:32:56 +0000 (18:32 +0000)
committerJason Kirtland <jek@discorporate.us>
Wed, 10 Feb 2010 18:32:56 +0000 (18:32 +0000)
CHANGES
lib/sqlalchemy/dialects/mysql/base.py
test/dialect/test_mysql.py

diff --git a/CHANGES b/CHANGES
index a9f22f242a24027e186ee4b36c210f4f067721d4..855293635afa961949e141411c2deb1c0deefbd7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -56,7 +56,10 @@ CHANGES
   - Fixed reflection bug whereby when COLLATE was present, 
     nullable flag and server defaults would not be reflected.
     [ticket:1655]
-    
+
+  - Fixed reflection of TINYINT(1) "boolean" columns defined with
+    integer flags like UNSIGNED.
+
 - mssql
   - Re-established initial support for pymssql.
   
index 77b13c1a736afad04a4c7c1fbb052ab6ea926768..eb348f1a16378bb64745874b4744fbf5f319fa73 100644 (file)
@@ -1084,7 +1084,7 @@ ischema_names = {
     'binary': BINARY,
     'bit': BIT,
     'blob': BLOB,
-    'boolean':BOOLEAN,
+    'boolean': BOOLEAN,
     'char': CHAR,
     'date': DATE,
     'datetime': DATETIME,
@@ -2154,7 +2154,6 @@ class MySQLTableDefinitionParser(object):
           Any column-bearing line from SHOW CREATE TABLE
         """
 
-        charset = state.charset
         spec = None
         m = self._re_column.match(line)
         if m:
@@ -2178,6 +2177,8 @@ class MySQLTableDefinitionParser(object):
         if type_ == 'tinyint' and args == '1':
             type_ = 'boolean'
             args = None
+            spec['unsigned'] = None
+            spec['zerofill'] = None
 
         try:
             col_type = self.dialect.ischema_names[type_]
index 0e9aca818186b930211f4f73a04bcfb3a1b170cd..85156ac3bfa0f3bb47866e28cda56f6a53cf60df 100644 (file)
@@ -359,12 +359,14 @@ class TypesTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
                            Column('b1', BOOLEAN),
                            Column('b2', Boolean),
                            Column('b3', mysql.MSTinyInteger(1)),
-                           Column('b4', mysql.MSTinyInteger))
+                           Column('b4', mysql.MSTinyInteger(1, unsigned=True)),
+                           Column('b5', mysql.MSTinyInteger))
 
         eq_(colspec(bool_table.c.b1), 'b1 BOOL')
         eq_(colspec(bool_table.c.b2), 'b2 BOOL')
         eq_(colspec(bool_table.c.b3), 'b3 TINYINT(1)')
-        eq_(colspec(bool_table.c.b4), 'b4 TINYINT')
+        eq_(colspec(bool_table.c.b4), 'b4 TINYINT(1) UNSIGNED')
+        eq_(colspec(bool_table.c.b5), 'b5 TINYINT')
 
         for col in bool_table.c:
             self.assert_(repr(col))
@@ -389,22 +391,23 @@ class TypesTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
                 table.delete().execute().close()
 
 
-            roundtrip([None, None, None, None])
-            roundtrip([True, True, 1, 1])
-            roundtrip([False, False, 0, 0])
-            roundtrip([True, True, True, True], [True, True, 1, 1])
-            roundtrip([False, False, 0, 0], [False, False, 0, 0])
+            roundtrip([None, None, None, None, None])
+            roundtrip([True, True, 1, 1, 1])
+            roundtrip([False, False, 0, 0, 0])
+            roundtrip([True, True, True, True, True], [True, True, 1, 1, 1])
+            roundtrip([False, False, 0, 0, 0], [False, False, 0, 0, 0])
 
             meta2 = MetaData(testing.db)
             # replace with reflected
             table = Table('mysql_bool', meta2, autoload=True)
             eq_(colspec(table.c.b3), 'b3 BOOL')
+            eq_(colspec(table.c.b4), 'b4 BOOL')
 
-            roundtrip([None, None, None, None])
-            roundtrip([True, True, 1, 1], [True, True, True, 1])
-            roundtrip([False, False, 0, 0], [False, False, False, 0])
-            roundtrip([True, True, True, True], [True, True, True, 1])
-            roundtrip([False, False, 0, 0], [False, False, False, 0])
+            roundtrip([None, None, None, None, None])
+            roundtrip([True, True, 1, 1, 1], [True, True, True, True, 1])
+            roundtrip([False, False, 0, 0, 0], [False, False, False, False, 0])
+            roundtrip([True, True, True, True, True], [True, True, True, True, 1])
+            roundtrip([False, False, 0, 0, 0], [False, False, False, False, 0])
         finally:
             meta.drop_all()