diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-08-24 21:20:05 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-08-24 21:20:05 +0000 |
commit | ae573e047a696c3c80d11e56466c9f55b72e0461 (patch) | |
tree | 7da54e41f789fc5dea306894d94eca6acd851d37 /lib/sqlalchemy/databases/mysql.py | |
parent | 4c29ed71d0f6ff656da4a04437097c290122f75c (diff) | |
download | sqlalchemy-ae573e047a696c3c80d11e56466c9f55b72e0461.tar.gz |
- Added MSMediumInteger type [ticket:1146].
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index ed8712748..729e1ad45 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -166,7 +166,7 @@ from sqlalchemy import types as sqltypes __all__ = ( - 'MSBigInteger', 'MSBinary', 'MSBit', 'MSBlob', 'MSBoolean', + 'MSBigInteger', 'MSMediumInteger', 'MSBinary', 'MSBit', 'MSBlob', 'MSBoolean', 'MSChar', 'MSDate', 'MSDateTime', 'MSDecimal', 'MSDouble', 'MSEnum', 'MSFloat', 'MSInteger', 'MSLongBlob', 'MSLongText', 'MSMediumBlob', 'MSMediumText', 'MSNChar', 'MSNVarChar', @@ -552,6 +552,33 @@ class MSBigInteger(MSInteger): else: return self._extend("BIGINT") +class MSMediumInteger(MSInteger): + """MySQL MEDIUMINTEGER type.""" + + def __init__(self, display_width=None, **kw): + """Construct a MEDIUMINTEGER + + display_width + Optional, maximum display width for this number. + + unsigned + Optional. + + zerofill + Optional. If true, values will be stored as strings left-padded with + zeros. Note that this does not effect the values returned by the + underlying database API, which continue to be numeric. + """ + + super(MSMediumInteger, self).__init__(display_width, **kw) + + def get_col_spec(self): + if self.display_width is not None: + return self._extend("MEDIUMINT(%(display_width)s)" % {'display_width': self.display_width}) + else: + return self._extend("MEDIUMINT") + + class MSTinyInteger(MSInteger): """MySQL TINYINT type.""" @@ -1404,7 +1431,7 @@ ischema_names = { 'longblob': MSLongBlob, 'longtext': MSLongText, 'mediumblob': MSMediumBlob, - 'mediumint': MSInteger, + 'mediumint': MSMediumInteger, 'mediumtext': MSMediumText, 'nchar': MSNChar, 'nvarchar': MSNVarChar, |