Commits

Mike Bayer committed 95ac46c

- No longer guessing that TINYINT(1) should be BOOLEAN
when reflecting - TINYINT(1) is returned. Use Boolean/
BOOLEAN in table definition to get boolean conversion
behavior. [ticket:1752]

Comments (0)

Files changed (3)

      argument 'precision' to both.   'precision' and 
      'timezone' are correctly reflected for both TIME and 
      TIMEZONE types. [ticket:997]
+
+- mysql
+   - No longer guessing that TINYINT(1) should be BOOLEAN
+     when reflecting - TINYINT(1) is returned.  Use Boolean/
+     BOOLEAN in table definition to get boolean conversion
+     behavior.  [ticket:1752]
      
 - oracle
    - The Oracle dialect will issue VARCHAR type definitions

lib/sqlalchemy/dialects/mysql/base.py

         name, type_, args, notnull = \
               spec['name'], spec['coltype'], spec['arg'], spec['notnull']
 
-        # Convention says that TINYINT(1) columns == BOOLEAN
-        if type_ == 'tinyint' and args == '1':
-            type_ = 'boolean'
-            args = None
-            spec['unsigned'] = None
-            spec['zerofill'] = None
-
         try:
             col_type = self.dialect.ischema_names[type_]
         except KeyError:

test/dialect/test_mysql.py

             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 TINYINT(1)')
+            eq_(colspec(table.c.b4), 'b4 TINYINT(1) UNSIGNED')
+
+            meta2 = MetaData(testing.db)
+            table = Table('mysql_bool', meta2, 
+                            Column('b1', BOOLEAN),
+                            Column('b2', Boolean),
+                            Column('b3', BOOLEAN), 
+                            Column('b4', BOOLEAN), 
+                            autoload=True)
             eq_(colspec(table.c.b3), 'b3 BOOL')
             eq_(colspec(table.c.b4), 'b4 BOOL')
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.