[Sqlalchemy-commits] [5054] sqlalchemy/trunk: - The 'length' argument to all Numeric types has been
Brought to you by:
zzzeek
From: <co...@sq...> - 2008-08-24 19:53:01
|
<!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>[5054] sqlalchemy/trunk: - The 'length' argument to all Numeric types has been renamed</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>5054</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2008-08-24 15:52:54 -0400 (Sun, 24 Aug 2008)</dd> </dl> <h3>Log Message</h3> <pre>- The 'length' argument to all Numeric types has been renamed to 'scale'. 'length' is deprecated and is still accepted with a warning. [ticket:827] - The 'length' argument to MSInteger, MSBigInteger, MSTinyInteger, MSSmallInteger and MSYear has been renamed to 'display_width'. [ticket:827] - mysql._Numeric now consumes 'unsigned' and 'zerofill' from the given kw, so that the same kw can be passed along to Numeric and allow the 'length' deprecation logic to still take effect - added testlib.engines.all_dialects() to return a dialect for every db module - informix added to sqlalchemy.databases.__all__. Since other "experimental" dbs like access and sybase are there, informix should be as well.</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunkCHANGES">sqlalchemy/trunk/CHANGES</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabases__init__py">sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesfirebirdpy">sqlalchemy/trunk/lib/sqlalchemy/databases/firebird.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesinformixpy">sqlalchemy/trunk/lib/sqlalchemy/databases/informix.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesmaxdbpy">sqlalchemy/trunk/lib/sqlalchemy/databases/maxdb.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesmssqlpy">sqlalchemy/trunk/lib/sqlalchemy/databases/mssql.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesmysqlpy">sqlalchemy/trunk/lib/sqlalchemy/databases/mysql.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasesoraclepy">sqlalchemy/trunk/lib/sqlalchemy/databases/oracle.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasespostgrespy">sqlalchemy/trunk/lib/sqlalchemy/databases/postgres.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasessqlitepy">sqlalchemy/trunk/lib/sqlalchemy/databases/sqlite.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemydatabasessybasepy">sqlalchemy/trunk/lib/sqlalchemy/databases/sybase.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemytypespy">sqlalchemy/trunk/lib/sqlalchemy/types.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemyutilpy">sqlalchemy/trunk/lib/sqlalchemy/util.py</a></li> <li><a href="#sqlalchemytrunktestdialectmysqlpy">sqlalchemy/trunk/test/dialect/mysql.py</a></li> <li><a href="#sqlalchemytrunktestsqlfunctionspy">sqlalchemy/trunk/test/sql/functions.py</a></li> <li><a href="#sqlalchemytrunktestsqltesttypespy">sqlalchemy/trunk/test/sql/testtypes.py</a></li> <li><a href="#sqlalchemytrunktesttestlibenginespy">sqlalchemy/trunk/test/testlib/engines.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunkCHANGES"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/CHANGES (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/CHANGES 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/CHANGES 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -77,12 +77,20 @@ </span><span class="cx"> removed from util.sort_tables(); use the Python </span><span class="cx"> 'reversed' function to reverse the results. </span><span class="cx"> [ticket:1033] </span><ins>+ + - The 'length' argument to all Numeric types has been renamed + to 'scale'. 'length' is deprecated and is still accepted + with a warning. </ins><span class="cx"> </span><span class="cx"> - sql </span><span class="cx"> - Temporarily rolled back the "ORDER BY" enhancement from </span><span class="cx"> [ticket:1068]. This feature is on hold pending further </span><span class="cx"> development. </span><span class="cx"> </span><ins>+- mysql + - The 'length' argument to MSInteger, MSBigInteger, MSTinyInteger, + MSSmallInteger and MSYear has been renamed to 'display_width'. + </ins><span class="cx"> 0.5beta3 </span><span class="cx"> ======== </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabases__init__py"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/__init__.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -8,6 +8,7 @@ </span><span class="cx"> __all__ = ( </span><span class="cx"> 'access', </span><span class="cx"> 'firebird', </span><ins>+ 'informix', </ins><span class="cx"> 'maxdb', </span><span class="cx"> 'mssql', </span><span class="cx"> 'mysql', </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesfirebirdpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/firebird.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/firebird.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/firebird.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -109,14 +109,14 @@ </span><span class="cx"> </span><span class="cx"> </span><span class="cx"> class FBNumeric(sqltypes.Numeric): </span><del>- """Handle ``NUMERIC(precision,length)`` datatype.""" </del><ins>+ """Handle ``NUMERIC(precision,scale)`` datatype.""" </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><span class="cx"> if self.precision is None: </span><span class="cx"> return "NUMERIC" </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % { 'precision': self.precision, - 'length' : self.length } </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % { 'precision': self.precision, + 'scale' : self.scale } </ins><span class="cx"> </span><span class="cx"> def bind_processor(self, dialect): </span><span class="cx"> return None </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesinformixpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/informix.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/informix.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/informix.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -45,7 +45,7 @@ </span><span class="cx"> if not self.precision: </span><span class="cx"> return 'NUMERIC' </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale} </ins><span class="cx"> </span><span class="cx"> class InfoInteger(sqltypes.Integer): </span><span class="cx"> def get_col_spec(self): </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesmaxdbpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/maxdb.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/maxdb.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/maxdb.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -169,17 +169,17 @@ </span><span class="cx"> class MaxNumeric(sqltypes.Numeric): </span><span class="cx"> """The FIXED (also NUMERIC, DECIMAL) data type.""" </span><span class="cx"> </span><del>- def __init__(self, precision=None, length=None, **kw): </del><ins>+ def __init__(self, precision=None, scale=None, **kw): </ins><span class="cx"> kw.setdefault('asdecimal', True) </span><del>- super(MaxNumeric, self).__init__(length=length, precision=precision, </del><ins>+ super(MaxNumeric, self).__init__(scale=scale, precision=precision, </ins><span class="cx"> **kw) </span><span class="cx"> </span><span class="cx"> def bind_processor(self, dialect): </span><span class="cx"> return None </span><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length and self.precision: - return 'FIXED(%s, %s)' % (self.precision, self.length) </del><ins>+ if self.scale and self.precision: + return 'FIXED(%s, %s)' % (self.precision, self.scale) </ins><span class="cx"> elif self.precision: </span><span class="cx"> return 'FIXED(%s)' % self.precision </span><span class="cx"> else: </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesmssqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/mssql.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/mssql.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/mssql.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -76,7 +76,7 @@ </span><span class="cx"> if self.precision is None: </span><span class="cx"> return "NUMERIC" </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale} </ins><span class="cx"> </span><span class="cx"> class MSFloat(sqltypes.Float): </span><span class="cx"> def get_col_spec(self): </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesmysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/mysql.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/mysql.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/mysql.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -231,9 +231,9 @@ </span><span class="cx"> class _NumericType(object): </span><span class="cx"> """Base for MySQL numeric types.""" </span><span class="cx"> </span><del>- def __init__(self, unsigned=False, zerofill=False, **kw): - self.unsigned = unsigned - self.zerofill = zerofill </del><ins>+ def __init__(self, kw): + self.unsigned = kw.pop('unsigned', False) + self.zerofill = kw.pop('zerofill', False) </ins><span class="cx"> </span><span class="cx"> def _extend(self, spec): </span><span class="cx"> "Extend a numeric-type declaration with MySQL specific extensions." </span><span class="lines">@@ -304,14 +304,14 @@ </span><span class="cx"> class MSNumeric(sqltypes.Numeric, _NumericType): </span><span class="cx"> """MySQL NUMERIC type.""" </span><span class="cx"> </span><del>- def __init__(self, precision=10, length=2, asdecimal=True, **kw): </del><ins>+ def __init__(self, precision=10, scale=2, asdecimal=True, **kw): </ins><span class="cx"> """Construct a NUMERIC. </span><span class="cx"> </span><span class="cx"> precision </span><del>- Total digits in this number. If length and precision are both </del><ins>+ Total digits in this number. If scale and precision are both </ins><span class="cx"> None, values are stored to limits allowed by the server. </span><span class="cx"> </span><del>- length </del><ins>+ scale </ins><span class="cx"> The number of digits after the decimal point. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -323,14 +323,14 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- _NumericType.__init__(self, **kw) - sqltypes.Numeric.__init__(self, precision, length, asdecimal=asdecimal) </del><ins>+ _NumericType.__init__(self, kw) + sqltypes.Numeric.__init__(self, precision, scale, asdecimal=asdecimal, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><span class="cx"> if self.precision is None: </span><span class="cx"> return self._extend("NUMERIC") </span><span class="cx"> else: </span><del>- return self._extend("NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}) </del><ins>+ return self._extend("NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}) </ins><span class="cx"> </span><span class="cx"> def bind_processor(self, dialect): </span><span class="cx"> return None </span><span class="lines">@@ -350,14 +350,14 @@ </span><span class="cx"> class MSDecimal(MSNumeric): </span><span class="cx"> """MySQL DECIMAL type.""" </span><span class="cx"> </span><del>- def __init__(self, precision=10, length=2, asdecimal=True, **kw): </del><ins>+ def __init__(self, precision=10, scale=2, asdecimal=True, **kw): </ins><span class="cx"> """Construct a DECIMAL. </span><span class="cx"> </span><span class="cx"> precision </span><del>- Total digits in this number. If length and precision are both None, </del><ins>+ Total digits in this number. If scale and precision are both None, </ins><span class="cx"> values are stored to limits allowed by the server. </span><span class="cx"> </span><del>- length </del><ins>+ scale </ins><span class="cx"> The number of digits after the decimal point. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -369,28 +369,28 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- super(MSDecimal, self).__init__(precision, length, asdecimal=asdecimal, **kw) </del><ins>+ super(MSDecimal, self).__init__(precision, scale, asdecimal=asdecimal, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><span class="cx"> if self.precision is None: </span><span class="cx"> return self._extend("DECIMAL") </span><del>- elif self.length is None: </del><ins>+ elif self.scale is None: </ins><span class="cx"> return self._extend("DECIMAL(%(precision)s)" % {'precision': self.precision}) </span><span class="cx"> else: </span><del>- return self._extend("DECIMAL(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}) </del><ins>+ return self._extend("DECIMAL(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}) </ins><span class="cx"> </span><span class="cx"> </span><span class="cx"> class MSDouble(sqltypes.Float, _NumericType): </span><span class="cx"> """MySQL DOUBLE type.""" </span><span class="cx"> </span><del>- def __init__(self, precision=None, length=None, asdecimal=True, **kw): </del><ins>+ def __init__(self, precision=None, scale=None, asdecimal=True, **kw): </ins><span class="cx"> """Construct a DOUBLE. </span><span class="cx"> </span><span class="cx"> precision </span><del>- Total digits in this number. If length and precision are both None, </del><ins>+ Total digits in this number. If scale and precision are both None, </ins><span class="cx"> values are stored to limits allowed by the server. </span><span class="cx"> </span><del>- length </del><ins>+ scale </ins><span class="cx"> The number of digits after the decimal point. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -402,22 +402,22 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- if ((precision is None and length is not None) or - (precision is not None and length is None)): </del><ins>+ if ((precision is None and scale is not None) or + (precision is not None and scale is None)): </ins><span class="cx"> raise exc.ArgumentError( </span><del>- "You must specify both precision and length or omit " </del><ins>+ "You must specify both precision and scale or omit " </ins><span class="cx"> "both altogether.") </span><span class="cx"> </span><del>- _NumericType.__init__(self, **kw) - sqltypes.Float.__init__(self, asdecimal=asdecimal) - self.length = length </del><ins>+ _NumericType.__init__(self, kw) + sqltypes.Float.__init__(self, asdecimal=asdecimal, **kw) + self.scale = scale </ins><span class="cx"> self.precision = precision </span><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.precision is not None and self.length is not None: - return self._extend("DOUBLE(%(precision)s, %(length)s)" % </del><ins>+ if self.precision is not None and self.scale is not None: + return self._extend("DOUBLE(%(precision)s, %(scale)s)" % </ins><span class="cx"> {'precision': self.precision, </span><del>- 'length' : self.length}) </del><ins>+ 'scale' : self.scale}) </ins><span class="cx"> else: </span><span class="cx"> return self._extend('DOUBLE') </span><span class="cx"> </span><span class="lines">@@ -425,14 +425,14 @@ </span><span class="cx"> class MSReal(MSDouble): </span><span class="cx"> """MySQL REAL type.""" </span><span class="cx"> </span><del>- def __init__(self, precision=None, length=None, asdecimal=True, **kw): </del><ins>+ def __init__(self, precision=None, scale=None, asdecimal=True, **kw): </ins><span class="cx"> """Construct a REAL. </span><span class="cx"> </span><span class="cx"> precision </span><del>- Total digits in this number. If length and precision are both None, </del><ins>+ Total digits in this number. If scale and precision are both None, </ins><span class="cx"> values are stored to limits allowed by the server. </span><span class="cx"> </span><del>- length </del><ins>+ scale </ins><span class="cx"> The number of digits after the decimal point. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -443,13 +443,13 @@ </span><span class="cx"> zeros. Note that this does not effect the values returned by the </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><del>- MSDouble.__init__(self, precision, length, asdecimal, **kw) </del><ins>+ MSDouble.__init__(self, precision, scale, asdecimal, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.precision is not None and self.length is not None: - return self._extend("REAL(%(precision)s, %(length)s)" % </del><ins>+ if self.precision is not None and self.scale is not None: + return self._extend("REAL(%(precision)s, %(scale)s)" % </ins><span class="cx"> {'precision': self.precision, </span><del>- 'length' : self.length}) </del><ins>+ 'scale' : self.scale}) </ins><span class="cx"> else: </span><span class="cx"> return self._extend('REAL') </span><span class="cx"> </span><span class="lines">@@ -457,14 +457,14 @@ </span><span class="cx"> class MSFloat(sqltypes.Float, _NumericType): </span><span class="cx"> """MySQL FLOAT type.""" </span><span class="cx"> </span><del>- def __init__(self, precision=None, length=None, asdecimal=False, **kw): </del><ins>+ def __init__(self, precision=None, scale=None, asdecimal=False, **kw): </ins><span class="cx"> """Construct a FLOAT. </span><span class="cx"> </span><span class="cx"> precision </span><del>- Total digits in this number. If length and precision are both None, </del><ins>+ Total digits in this number. If scale and precision are both None, </ins><span class="cx"> values are stored to limits allowed by the server. </span><span class="cx"> </span><del>- length </del><ins>+ scale </ins><span class="cx"> The number of digits after the decimal point. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -476,14 +476,14 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- _NumericType.__init__(self, **kw) - sqltypes.Float.__init__(self, asdecimal=asdecimal) - self.length = length </del><ins>+ _NumericType.__init__(self, kw) + sqltypes.Float.__init__(self, asdecimal=asdecimal, **kw) + self.scale = scale </ins><span class="cx"> self.precision = precision </span><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is not None and self.precision is not None: - return self._extend("FLOAT(%s, %s)" % (self.precision, self.length)) </del><ins>+ if self.scale is not None and self.precision is not None: + return self._extend("FLOAT(%s, %s)" % (self.precision, self.scale)) </ins><span class="cx"> elif self.precision is not None: </span><span class="cx"> return self._extend("FLOAT(%s)" % (self.precision,)) </span><span class="cx"> else: </span><span class="lines">@@ -496,10 +496,10 @@ </span><span class="cx"> class MSInteger(sqltypes.Integer, _NumericType): </span><span class="cx"> """MySQL INTEGER type.""" </span><span class="cx"> </span><del>- def __init__(self, length=None, **kw): </del><ins>+ def __init__(self, display_width=None, **kw): </ins><span class="cx"> """Construct an INTEGER. </span><span class="cx"> </span><del>- length </del><ins>+ display_width </ins><span class="cx"> Optional, maximum display width for this number. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -511,13 +511,17 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- self.length = length - _NumericType.__init__(self, **kw) - sqltypes.Integer.__init__(self) </del><ins>+ if 'length' in kw: + util.warn_deprecated("'length' is deprecated for MSInteger and subclasses. Use 'display_width'.") + self.display_width = kw.pop('length') + else: + self.display_width = display_width + _NumericType.__init__(self, kw) + sqltypes.Integer.__init__(self, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is not None: - return self._extend("INTEGER(%(length)s)" % {'length': self.length}) </del><ins>+ if self.display_width is not None: + return self._extend("INTEGER(%(display_width)s)" % {'display_width': self.display_width}) </ins><span class="cx"> else: </span><span class="cx"> return self._extend("INTEGER") </span><span class="cx"> </span><span class="lines">@@ -525,10 +529,10 @@ </span><span class="cx"> class MSBigInteger(MSInteger): </span><span class="cx"> """MySQL BIGINTEGER type.""" </span><span class="cx"> </span><del>- def __init__(self, length=None, **kw): </del><ins>+ def __init__(self, display_width=None, **kw): </ins><span class="cx"> """Construct a BIGINTEGER. </span><span class="cx"> </span><del>- length </del><ins>+ display_width </ins><span class="cx"> Optional, maximum display width for this number. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -540,11 +544,11 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- super(MSBigInteger, self).__init__(length, **kw) </del><ins>+ super(MSBigInteger, self).__init__(display_width, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is not None: - return self._extend("BIGINT(%(length)s)" % {'length': self.length}) </del><ins>+ if self.display_width is not None: + return self._extend("BIGINT(%(display_width)s)" % {'display_width': self.display_width}) </ins><span class="cx"> else: </span><span class="cx"> return self._extend("BIGINT") </span><span class="cx"> </span><span class="lines">@@ -552,14 +556,14 @@ </span><span class="cx"> class MSTinyInteger(MSInteger): </span><span class="cx"> """MySQL TINYINT type.""" </span><span class="cx"> </span><del>- def __init__(self, length=None, **kw): </del><ins>+ def __init__(self, display_width=None, **kw): </ins><span class="cx"> """Construct a TINYINT. </span><span class="cx"> </span><span class="cx"> Note: following the usual MySQL conventions, TINYINT(1) columns </span><span class="cx"> reflected during Table(..., autoload=True) are treated as </span><span class="cx"> Boolean columns. </span><span class="cx"> </span><del>- length </del><ins>+ display_width </ins><span class="cx"> Optional, maximum display width for this number. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -571,11 +575,11 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- super(MSTinyInteger, self).__init__(length, **kw) </del><ins>+ super(MSTinyInteger, self).__init__(display_width, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is not None: - return self._extend("TINYINT(%s)" % self.length) </del><ins>+ if self.display_width is not None: + return self._extend("TINYINT(%s)" % self.display_width) </ins><span class="cx"> else: </span><span class="cx"> return self._extend("TINYINT") </span><span class="cx"> </span><span class="lines">@@ -583,10 +587,10 @@ </span><span class="cx"> class MSSmallInteger(sqltypes.Smallinteger, MSInteger): </span><span class="cx"> """MySQL SMALLINTEGER type.""" </span><span class="cx"> </span><del>- def __init__(self, length=None, **kw): </del><ins>+ def __init__(self, display_width=None, **kw): </ins><span class="cx"> """Construct a SMALLINTEGER. </span><span class="cx"> </span><del>- length </del><ins>+ display_width </ins><span class="cx"> Optional, maximum display width for this number. </span><span class="cx"> </span><span class="cx"> unsigned </span><span class="lines">@@ -598,13 +602,13 @@ </span><span class="cx"> underlying database API, which continue to be numeric. </span><span class="cx"> """ </span><span class="cx"> </span><del>- self.length = length - _NumericType.__init__(self, **kw) - sqltypes.SmallInteger.__init__(self, length) </del><ins>+ self.display_width = display_width + _NumericType.__init__(self, kw) + sqltypes.SmallInteger.__init__(self, **kw) </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is not None: - return self._extend("SMALLINT(%(length)s)" % {'length': self.length}) </del><ins>+ if self.display_width is not None: + return self._extend("SMALLINT(%(display_width)s)" % {'display_width': self.display_width}) </ins><span class="cx"> else: </span><span class="cx"> return self._extend("SMALLINT") </span><span class="cx"> </span><span class="lines">@@ -690,14 +694,14 @@ </span><span class="cx"> class MSYear(sqltypes.TypeEngine): </span><span class="cx"> """MySQL YEAR type, for single byte storage of years 1901-2155.""" </span><span class="cx"> </span><del>- def __init__(self, length=None): - self.length = length </del><ins>+ def __init__(self, display_width=None): + self.display_width = display_width </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is None: </del><ins>+ if self.display_width is None: </ins><span class="cx"> return "YEAR" </span><span class="cx"> else: </span><del>- return "YEAR(%s)" % self.length </del><ins>+ return "YEAR(%s)" % self.display_width </ins><span class="cx"> </span><span class="cx"> class MSText(_StringType, sqltypes.Text): </span><span class="cx"> """MySQL TEXT type, for text up to 2^16 characters.""" </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasesoraclepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/oracle.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/oracle.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/oracle.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -19,7 +19,7 @@ </span><span class="cx"> if self.precision is None: </span><span class="cx"> return "NUMERIC" </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale} </ins><span class="cx"> </span><span class="cx"> class OracleInteger(sqltypes.Integer): </span><span class="cx"> def get_col_spec(self): </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasespostgrespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/postgres.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/postgres.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/postgres.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -45,7 +45,7 @@ </span><span class="cx"> if not self.precision: </span><span class="cx"> return "NUMERIC" </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale} </ins><span class="cx"> </span><span class="cx"> def bind_processor(self, dialect): </span><span class="cx"> return None </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasessqlitepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/sqlite.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/sqlite.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/sqlite.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -30,7 +30,7 @@ </span><span class="cx"> if self.precision is None: </span><span class="cx"> return "NUMERIC" </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale} </ins><span class="cx"> </span><span class="cx"> class SLFloat(sqltypes.Float): </span><span class="cx"> def bind_processor(self, dialect): </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemydatabasessybasepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/databases/sybase.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/databases/sybase.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/databases/sybase.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -168,18 +168,18 @@ </span><span class="cx"> </span><span class="cx"> class SybaseNumeric(sqltypes.Numeric): </span><span class="cx"> def get_col_spec(self): </span><del>- if self.length is None: </del><ins>+ if self.scale is None: </ins><span class="cx"> if self.precision is None: </span><span class="cx"> return "NUMERIC" </span><span class="cx"> else: </span><span class="cx"> return "NUMERIC(%(precision)s)" % {'precision' : self.precision} </span><span class="cx"> else: </span><del>- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length} </del><ins>+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale} </ins><span class="cx"> </span><span class="cx"> class SybaseFloat(sqltypes.FLOAT, SybaseNumeric): </span><del>- def __init__(self, precision = 10, asdecimal = False, length = 2, **kwargs): </del><ins>+ def __init__(self, precision = 10, asdecimal = False, scale = 2, **kwargs): </ins><span class="cx"> super(sqltypes.FLOAT, self).__init__(precision, asdecimal, **kwargs) </span><del>- self.length = length </del><ins>+ self.scale = scale </ins><span class="cx"> </span><span class="cx"> def get_col_spec(self): </span><span class="cx"> # if asdecimal is True, handle same way as SybaseNumeric </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemytypespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/types.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/types.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/types.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -450,13 +450,16 @@ </span><span class="cx"> class Numeric(TypeEngine): </span><span class="cx"> """Numeric datatype, usually resolves to DECIMAL or NUMERIC.""" </span><span class="cx"> </span><del>- def __init__(self, precision=10, length=2, asdecimal=True): </del><ins>+ def __init__(self, precision=10, scale=2, asdecimal=True, length=None): + if length: + util.warn_deprecated("'length' is deprecated for Numeric. Use 'scale'.") + scale = length </ins><span class="cx"> self.precision = precision </span><del>- self.length = length </del><ins>+ self.scale = scale </ins><span class="cx"> self.asdecimal = asdecimal </span><span class="cx"> </span><span class="cx"> def adapt(self, impltype): </span><del>- return impltype(precision=self.precision, length=self.length, asdecimal=self.asdecimal) </del><ins>+ return impltype(precision=self.precision, scale=self.scale, asdecimal=self.asdecimal) </ins><span class="cx"> </span><span class="cx"> def get_dbapi_type(self, dbapi): </span><span class="cx"> return dbapi.NUMBER </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemyutilpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/util.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/util.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/lib/sqlalchemy/util.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -380,6 +380,7 @@ </span><span class="cx"> else: </span><span class="cx"> return (['self'], 'args', 'kwargs', None) </span><span class="cx"> </span><ins>+ </ins><span class="cx"> def unbound_method_to_callable(func_or_cls): </span><span class="cx"> """Adjust the incoming callable such that a 'self' argument is not required.""" </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunktestdialectmysqlpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/dialect/mysql.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/dialect/mysql.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/test/dialect/mysql.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -659,7 +659,7 @@ </span><span class="cx"> ( mysql.MSNChar(2), mysql.MSChar(2), ), # N is CREATE only </span><span class="cx"> ( mysql.MSNVarChar(22), mysql.MSString(22), ), </span><span class="cx"> ( SmallInteger(), mysql.MSSmallInteger(), ), </span><del>- ( SmallInteger(4), mysql.MSSmallInteger(4), ), </del><ins>+ ( SmallInteger(), mysql.MSSmallInteger(4), ), </ins><span class="cx"> ( mysql.MSSmallInteger(), ), </span><span class="cx"> ( mysql.MSSmallInteger(4), mysql.MSSmallInteger(4), ), </span><span class="cx"> ( Binary(3), mysql.MSBlob(3), ), </span></span></pre></div> <a id="sqlalchemytrunktestsqlfunctionspy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/sql/functions.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/sql/functions.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/test/sql/functions.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -5,22 +5,16 @@ </span><span class="cx"> from sqlalchemy import databases, sql, util </span><span class="cx"> from sqlalchemy.sql.compiler import BIND_TEMPLATES </span><span class="cx"> from sqlalchemy.engine import default </span><ins>+from testlib.engines import all_dialects </ins><span class="cx"> from sqlalchemy import types as sqltypes </span><span class="cx"> from testlib import * </span><span class="cx"> from sqlalchemy.sql.functions import GenericFunction </span><span class="cx"> from testlib.testing import eq_ </span><span class="cx"> </span><span class="cx"> from sqlalchemy.databases import * </span><del>-# every dialect in databases.__all__ is expected to pass these tests. -dialects = [getattr(databases, mod).dialect() - for mod in databases.__all__ - # fixme! - if mod not in ('access',)] </del><span class="cx"> </span><del>-# if the configured dialect is out-of-tree or not yet in __all__, include it -# too. -if testing.db.name not in databases.__all__: - dialects.append(testing.db.dialect) </del><ins>+# FIXME! +dialects = [d for d in all_dialects() if d.name not in ('access', 'informix')] </ins><span class="cx"> </span><span class="cx"> </span><span class="cx"> class CompileTest(TestBase, AssertsCompiledSQL): </span></span></pre></div> <a id="sqlalchemytrunktestsqltesttypespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/sql/testtypes.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/sql/testtypes.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/test/sql/testtypes.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -4,6 +4,7 @@ </span><span class="cx"> from sqlalchemy import * </span><span class="cx"> from sqlalchemy import exc, types, util </span><span class="cx"> from sqlalchemy.sql import operators </span><ins>+from testlib.testing import eq_ </ins><span class="cx"> import sqlalchemy.engine.url as url </span><span class="cx"> from sqlalchemy.databases import mssql, oracle, mysql, postgres, firebird </span><span class="cx"> from testlib import * </span><span class="lines">@@ -728,7 +729,34 @@ </span><span class="cx"> assert isinstance(row['ncasdec'], decimal.Decimal) </span><span class="cx"> assert isinstance(row['fcasdec'], decimal.Decimal) </span><span class="cx"> </span><del>- </del><ins>+ def test_length_deprecation(self): + self.assertRaises(exc.SADeprecationWarning, Numeric, length=8) + + @testing.uses_deprecated(".*is deprecated for Numeric") + def go(): + n = Numeric(length=12) + assert n.scale == 12 + go() + + n = Numeric(scale=12) + for dialect in engines.all_dialects(): + n2 = dialect.type_descriptor(n) + eq_(n2.scale, 12, dialect.name) + + # test colspec generates successfully using 'scale' + assert n2.get_col_spec() + + # test constructor of the dialect-specific type + n3 = n2.__class__(scale=5) + eq_(n3.scale, 5, dialect.name) + + @testing.uses_deprecated(".*is deprecated for Numeric") + def go(): + n3 = n2.__class__(length=6) + eq_(n3.scale, 6, dialect.name) + go() + + </ins><span class="cx"> class IntervalTest(TestBase, AssertsExecutionResults): </span><span class="cx"> def setUpAll(self): </span><span class="cx"> global interval_table, metadata </span></span></pre></div> <a id="sqlalchemytrunktesttestlibenginespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/testlib/engines.py (5053 => 5054)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/testlib/engines.py 2008-08-23 19:38:04 UTC (rev 5053) +++ sqlalchemy/trunk/test/testlib/engines.py 2008-08-24 19:52:54 UTC (rev 5054) </span><span class="lines">@@ -66,6 +66,12 @@ </span><span class="cx"> testing_reaper.close_all() </span><span class="cx"> return _function_named(decorated, fn.__name__) </span><span class="cx"> </span><ins>+def all_dialects(): + import sqlalchemy.databases as d + for name in d.__all__: + mod = getattr(__import__('sqlalchemy.databases.%s' % name).databases, name) + yield mod.dialect() + </ins><span class="cx"> class ReconnectFixture(object): </span><span class="cx"> def __init__(self, dbapi): </span><span class="cx"> self.dbapi = dbapi </span></span></pre> </div> </div> </body> </html> |