[Sqlalchemy-commits] [5057] sqlalchemy/branches/rel_0_4: - Added MSMediumInteger type [ticket: 1146
Brought to you by:
zzzeek
From: <co...@sq...> - 2008-08-24 21:20:16
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[5057] sqlalchemy/branches/rel_0_4: - Added MSMediumInteger type [ticket: 1146].</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>5057</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2008-08-24 17:20:15 -0400 (Sun, 24 Aug 2008)</dd> </dl> <h3>Log Message</h3> <pre>- Added MSMediumInteger type [ticket:1146].</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemybranchesrel_0_4CHANGES">sqlalchemy/branches/rel_0_4/CHANGES</a></li> <li><a href="#sqlalchemybranchesrel_0_4libsqlalchemydatabasesmysqlpy">sqlalchemy/branches/rel_0_4/lib/sqlalchemy/databases/mysql.py</a></li> <li><a href="#sqlalchemybranchesrel_0_4testdialectmysqlpy">sqlalchemy/branches/rel_0_4/test/dialect/mysql.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemybranchesrel_0_4CHANGES"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_4/CHANGES (5056 => 5057)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_4/CHANGES 2008-08-24 21:20:05 UTC (rev 5056) +++ sqlalchemy/branches/rel_0_4/CHANGES 2008-08-24 21:20:15 UTC (rev 5057) </span><span class="lines">@@ -7,6 +7,9 @@ </span><span class="cx"> - Fixed bug regarding inherit_condition passed </span><span class="cx"> with "A=B" versus "B=A" leading to errors </span><span class="cx"> [ticket:1039] </span><ins>+ +- mysql + - Added MSMediumInteger type [ticket:1146]. </ins><span class="cx"> </span><span class="cx"> 0.4.7p1 </span><span class="cx"> ===== </span></span></pre></div> <a id="sqlalchemybranchesrel_0_4libsqlalchemydatabasesmysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_4/lib/sqlalchemy/databases/mysql.py (5056 => 5057)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_4/lib/sqlalchemy/databases/mysql.py 2008-08-24 21:20:05 UTC (rev 5056) +++ sqlalchemy/branches/rel_0_4/lib/sqlalchemy/databases/mysql.py 2008-08-24 21:20:15 UTC (rev 5057) </span><span class="lines">@@ -166,7 +166,7 @@ </span><span class="cx"> </span><span class="cx"> </span><span class="cx"> __all__ = ( </span><del>- 'MSBigInteger', 'MSBinary', 'MSBit', 'MSBlob', 'MSBoolean', </del><ins>+ 'MSBigInteger', 'MSMediumInteger', 'MSBinary', 'MSBit', 'MSBlob', 'MSBoolean', </ins><span class="cx"> 'MSChar', 'MSDate', 'MSDateTime', 'MSDecimal', 'MSDouble', </span><span class="cx"> 'MSEnum', 'MSFloat', 'MSInteger', 'MSLongBlob', 'MSLongText', </span><span class="cx"> 'MSMediumBlob', 'MSMediumText', 'MSNChar', 'MSNVarChar', </span><span class="lines">@@ -548,7 +548,34 @@ </span><span class="cx"> else: </span><span class="cx"> return self._extend("BIGINT") </span><span class="cx"> </span><ins>+class MSMediumInteger(MSInteger): + """MySQL MEDIUMINTEGER type.""" </ins><span class="cx"> </span><ins>+ def __init__(self, length=None, **kw): + """Construct a MEDIUMINTEGER + + length + 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__(length, **kw) + + def get_col_spec(self): + if self.length is not None: + return self._extend("MEDIUMINT(%(length)s)" % {'length': self.length}) + else: + return self._extend("MEDIUMINT") + + + </ins><span class="cx"> class MSTinyInteger(MSInteger): </span><span class="cx"> """MySQL TINYINT type.""" </span><span class="cx"> </span><span class="lines">@@ -1363,7 +1390,7 @@ </span><span class="cx"> 'longblob': MSLongBlob, </span><span class="cx"> 'longtext': MSLongText, </span><span class="cx"> 'mediumblob': MSMediumBlob, </span><del>- 'mediumint': MSInteger, </del><ins>+ 'mediumint': MSMediumInteger, </ins><span class="cx"> 'mediumtext': MSMediumText, </span><span class="cx"> 'nchar': MSNChar, </span><span class="cx"> 'nvarchar': MSNVarChar, </span></span></pre></div> <a id="sqlalchemybranchesrel_0_4testdialectmysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/branches/rel_0_4/test/dialect/mysql.py (5056 => 5057)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/branches/rel_0_4/test/dialect/mysql.py 2008-08-24 21:20:05 UTC (rev 5056) +++ sqlalchemy/branches/rel_0_4/test/dialect/mysql.py 2008-08-24 21:20:15 UTC (rev 5057) </span><span class="lines">@@ -23,6 +23,7 @@ </span><span class="cx"> Column('num3', mysql.MSBigInteger()), </span><span class="cx"> Column('num4', mysql.MSDouble), </span><span class="cx"> Column('num5', mysql.MSDouble()), </span><ins>+ Column('num6', mysql.MSMediumInteger), </ins><span class="cx"> Column('enum1', mysql.MSEnum("'black'", "'white'")), </span><span class="cx"> ) </span><span class="cx"> try: </span><span class="lines">@@ -38,6 +39,7 @@ </span><span class="cx"> assert isinstance(t2.c.num3.type, mysql.MSBigInteger) </span><span class="cx"> assert isinstance(t2.c.num4.type, mysql.MSDouble) </span><span class="cx"> assert isinstance(t2.c.num5.type, mysql.MSDouble) </span><ins>+ assert isinstance(t2.c.num6.type, mysql.MSMediumInteger) </ins><span class="cx"> assert isinstance(t2.c.enum1.type, mysql.MSEnum) </span><span class="cx"> t2.drop() </span><span class="cx"> t2.create() </span><span class="lines">@@ -133,6 +135,17 @@ </span><span class="cx"> (mysql.MSBigInteger, [4], {'zerofill':True, 'unsigned':True}, </span><span class="cx"> 'BIGINT(4) UNSIGNED ZEROFILL'), </span><span class="cx"> </span><ins>+ (mysql.MSMediumInteger, [], {}, + 'MEDIUMINT'), + (mysql.MSMediumInteger, [4], {}, + 'MEDIUMINT(4)'), + (mysql.MSMediumInteger, [4], {'unsigned':True}, + 'MEDIUMINT(4) UNSIGNED'), + (mysql.MSMediumInteger, [4], {'zerofill':True}, + 'MEDIUMINT(4) ZEROFILL'), + (mysql.MSMediumInteger, [4], {'zerofill':True, 'unsigned':True}, + 'MEDIUMINT(4) UNSIGNED ZEROFILL'), + </ins><span class="cx"> (mysql.MSTinyInteger, [], {}, </span><span class="cx"> 'TINYINT'), </span><span class="cx"> (mysql.MSTinyInteger, [1], {}, </span><span class="lines">@@ -645,6 +658,8 @@ </span><span class="cx"> ( SmallInteger(4), mysql.MSSmallInteger(4), ), </span><span class="cx"> ( mysql.MSSmallInteger(), ), </span><span class="cx"> ( mysql.MSSmallInteger(4), mysql.MSSmallInteger(4), ), </span><ins>+ ( mysql.MSMediumInteger(), mysql.MSMediumInteger(), ), + ( mysql.MSMediumInteger(8), mysql.MSMediumInteger(8), ), </ins><span class="cx"> ( Binary(3), mysql.MSBlob(3), ), </span><span class="cx"> ( Binary(), mysql.MSBlob() ), </span><span class="cx"> ( mysql.MSBinary(3), mysql.MSBinary(3), ), </span></span></pre> </div> </div> </body> </html> |