summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2010-02-10 18:32:56 +0000
committerJason Kirtland <jek@discorporate.us>2010-02-10 18:32:56 +0000
commitbef9e234de84a1601df4d324feb5c422818a6d3d (patch)
treedc6d71ea742b46c8890f900776f8d09fa0256bee
parent2d03b0848353dd483beb5800582bb1c94e96497b (diff)
downloadsqlalchemy-bef9e234de84a1601df4d324feb5c422818a6d3d.tar.gz
Fix mysql reflection of TINYINT(1) UNSIGNED columns.
-rw-r--r--CHANGES5
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py5
-rw-r--r--test/dialect/test_mysql.py27
3 files changed, 22 insertions, 15 deletions
diff --git a/CHANGES b/CHANGES
index a9f22f242..855293635 100644
--- 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.
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 77b13c1a7..eb348f1a1 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -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_]
diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py
index 0e9aca818..85156ac3b 100644
--- a/test/dialect/test_mysql.py
+++ b/test/dialect/test_mysql.py
@@ -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()