summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-08-24 19:52:54 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-08-24 19:52:54 +0000
commit6f60e768837f6b91a75dc2d62dbd215471bf09f7 (patch)
tree3db99506d1901e0e809821816d899e8a81a8d370
parente01e972ac305d634cac3d63de6c5fa6688cd56c5 (diff)
downloadsqlalchemy-6f60e768837f6b91a75dc2d62dbd215471bf09f7.tar.gz
- 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.
-rw-r--r--CHANGES8
-rw-r--r--lib/sqlalchemy/databases/__init__.py1
-rw-r--r--lib/sqlalchemy/databases/firebird.py6
-rw-r--r--lib/sqlalchemy/databases/informix.py2
-rw-r--r--lib/sqlalchemy/databases/maxdb.py8
-rw-r--r--lib/sqlalchemy/databases/mssql.py2
-rw-r--r--lib/sqlalchemy/databases/mysql.py144
-rw-r--r--lib/sqlalchemy/databases/oracle.py2
-rw-r--r--lib/sqlalchemy/databases/postgres.py2
-rw-r--r--lib/sqlalchemy/databases/sqlite.py2
-rw-r--r--lib/sqlalchemy/databases/sybase.py8
-rw-r--r--lib/sqlalchemy/types.py9
-rw-r--r--lib/sqlalchemy/util.py1
-rw-r--r--test/dialect/mysql.py2
-rw-r--r--test/sql/functions.py14
-rw-r--r--test/sql/testtypes.py30
-rw-r--r--test/testlib/engines.py6
17 files changed, 146 insertions, 101 deletions
diff --git a/CHANGES b/CHANGES
index e5746ea3e..8e7c50ecf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -77,12 +77,20 @@ CHANGES
removed from util.sort_tables(); use the Python
'reversed' function to reverse the results.
[ticket:1033]
+
+ - The 'length' argument to all Numeric types has been renamed
+ to 'scale'. 'length' is deprecated and is still accepted
+ with a warning.
- sql
- Temporarily rolled back the "ORDER BY" enhancement from
[ticket:1068]. This feature is on hold pending further
development.
+- mysql
+ - The 'length' argument to MSInteger, MSBigInteger, MSTinyInteger,
+ MSSmallInteger and MSYear has been renamed to 'display_width'.
+
0.5beta3
========
diff --git a/lib/sqlalchemy/databases/__init__.py b/lib/sqlalchemy/databases/__init__.py
index 9837cd136..ec7ac6902 100644
--- a/lib/sqlalchemy/databases/__init__.py
+++ b/lib/sqlalchemy/databases/__init__.py
@@ -8,6 +8,7 @@
__all__ = (
'access',
'firebird',
+ 'informix',
'maxdb',
'mssql',
'mysql',
diff --git a/lib/sqlalchemy/databases/firebird.py b/lib/sqlalchemy/databases/firebird.py
index b2fcea095..ccd4db3c7 100644
--- a/lib/sqlalchemy/databases/firebird.py
+++ b/lib/sqlalchemy/databases/firebird.py
@@ -109,14 +109,14 @@ _initialized_kb = False
class FBNumeric(sqltypes.Numeric):
- """Handle ``NUMERIC(precision,length)`` datatype."""
+ """Handle ``NUMERIC(precision,scale)`` datatype."""
def get_col_spec(self):
if self.precision is None:
return "NUMERIC"
else:
- return "NUMERIC(%(precision)s, %(length)s)" % { 'precision': self.precision,
- 'length' : self.length }
+ return "NUMERIC(%(precision)s, %(scale)s)" % { 'precision': self.precision,
+ 'scale' : self.scale }
def bind_processor(self, dialect):
return None
diff --git a/lib/sqlalchemy/databases/informix.py b/lib/sqlalchemy/databases/informix.py
index e5f400770..423226c18 100644
--- a/lib/sqlalchemy/databases/informix.py
+++ b/lib/sqlalchemy/databases/informix.py
@@ -45,7 +45,7 @@ class InfoNumeric(sqltypes.Numeric):
if not self.precision:
return 'NUMERIC'
else:
- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}
class InfoInteger(sqltypes.Integer):
def get_col_spec(self):
diff --git a/lib/sqlalchemy/databases/maxdb.py b/lib/sqlalchemy/databases/maxdb.py
index c9ea2b579..34629b298 100644
--- a/lib/sqlalchemy/databases/maxdb.py
+++ b/lib/sqlalchemy/databases/maxdb.py
@@ -169,17 +169,17 @@ class MaxSmallInteger(MaxInteger):
class MaxNumeric(sqltypes.Numeric):
"""The FIXED (also NUMERIC, DECIMAL) data type."""
- def __init__(self, precision=None, length=None, **kw):
+ def __init__(self, precision=None, scale=None, **kw):
kw.setdefault('asdecimal', True)
- super(MaxNumeric, self).__init__(length=length, precision=precision,
+ super(MaxNumeric, self).__init__(scale=scale, precision=precision,
**kw)
def bind_processor(self, dialect):
return None
def get_col_spec(self):
- if self.length and self.precision:
- return 'FIXED(%s, %s)' % (self.precision, self.length)
+ if self.scale and self.precision:
+ return 'FIXED(%s, %s)' % (self.precision, self.scale)
elif self.precision:
return 'FIXED(%s)' % self.precision
else:
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py
index cfb34dd78..a2535754d 100644
--- a/lib/sqlalchemy/databases/mssql.py
+++ b/lib/sqlalchemy/databases/mssql.py
@@ -76,7 +76,7 @@ class MSNumeric(sqltypes.Numeric):
if self.precision is None:
return "NUMERIC"
else:
- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}
class MSFloat(sqltypes.Float):
def get_col_spec(self):
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 4a4cfbd90..46e692463 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -231,9 +231,9 @@ SET_RE = re.compile(
class _NumericType(object):
"""Base for MySQL numeric types."""
- def __init__(self, unsigned=False, zerofill=False, **kw):
- self.unsigned = unsigned
- self.zerofill = zerofill
+ def __init__(self, kw):
+ self.unsigned = kw.pop('unsigned', False)
+ self.zerofill = kw.pop('zerofill', False)
def _extend(self, spec):
"Extend a numeric-type declaration with MySQL specific extensions."
@@ -304,14 +304,14 @@ class _StringType(object):
class MSNumeric(sqltypes.Numeric, _NumericType):
"""MySQL NUMERIC type."""
- def __init__(self, precision=10, length=2, asdecimal=True, **kw):
+ def __init__(self, precision=10, scale=2, asdecimal=True, **kw):
"""Construct a NUMERIC.
precision
- Total digits in this number. If length and precision are both
+ Total digits in this number. If scale and precision are both
None, values are stored to limits allowed by the server.
- length
+ scale
The number of digits after the decimal point.
unsigned
@@ -323,14 +323,14 @@ class MSNumeric(sqltypes.Numeric, _NumericType):
underlying database API, which continue to be numeric.
"""
- _NumericType.__init__(self, **kw)
- sqltypes.Numeric.__init__(self, precision, length, asdecimal=asdecimal)
+ _NumericType.__init__(self, kw)
+ sqltypes.Numeric.__init__(self, precision, scale, asdecimal=asdecimal, **kw)
def get_col_spec(self):
if self.precision is None:
return self._extend("NUMERIC")
else:
- return self._extend("NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length})
+ return self._extend("NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale})
def bind_processor(self, dialect):
return None
@@ -350,14 +350,14 @@ class MSNumeric(sqltypes.Numeric, _NumericType):
class MSDecimal(MSNumeric):
"""MySQL DECIMAL type."""
- def __init__(self, precision=10, length=2, asdecimal=True, **kw):
+ def __init__(self, precision=10, scale=2, asdecimal=True, **kw):
"""Construct a DECIMAL.
precision
- Total digits in this number. If length and precision are both None,
+ Total digits in this number. If scale and precision are both None,
values are stored to limits allowed by the server.
- length
+ scale
The number of digits after the decimal point.
unsigned
@@ -369,28 +369,28 @@ class MSDecimal(MSNumeric):
underlying database API, which continue to be numeric.
"""
- super(MSDecimal, self).__init__(precision, length, asdecimal=asdecimal, **kw)
+ super(MSDecimal, self).__init__(precision, scale, asdecimal=asdecimal, **kw)
def get_col_spec(self):
if self.precision is None:
return self._extend("DECIMAL")
- elif self.length is None:
+ elif self.scale is None:
return self._extend("DECIMAL(%(precision)s)" % {'precision': self.precision})
else:
- return self._extend("DECIMAL(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length})
+ return self._extend("DECIMAL(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale})
class MSDouble(sqltypes.Float, _NumericType):
"""MySQL DOUBLE type."""
- def __init__(self, precision=None, length=None, asdecimal=True, **kw):
+ def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
"""Construct a DOUBLE.
precision
- Total digits in this number. If length and precision are both None,
+ Total digits in this number. If scale and precision are both None,
values are stored to limits allowed by the server.
- length
+ scale
The number of digits after the decimal point.
unsigned
@@ -402,22 +402,22 @@ class MSDouble(sqltypes.Float, _NumericType):
underlying database API, which continue to be numeric.
"""
- if ((precision is None and length is not None) or
- (precision is not None and length is None)):
+ if ((precision is None and scale is not None) or
+ (precision is not None and scale is None)):
raise exc.ArgumentError(
- "You must specify both precision and length or omit "
+ "You must specify both precision and scale or omit "
"both altogether.")
- _NumericType.__init__(self, **kw)
- sqltypes.Float.__init__(self, asdecimal=asdecimal)
- self.length = length
+ _NumericType.__init__(self, kw)
+ sqltypes.Float.__init__(self, asdecimal=asdecimal, **kw)
+ self.scale = scale
self.precision = precision
def get_col_spec(self):
- if self.precision is not None and self.length is not None:
- return self._extend("DOUBLE(%(precision)s, %(length)s)" %
+ if self.precision is not None and self.scale is not None:
+ return self._extend("DOUBLE(%(precision)s, %(scale)s)" %
{'precision': self.precision,
- 'length' : self.length})
+ 'scale' : self.scale})
else:
return self._extend('DOUBLE')
@@ -425,14 +425,14 @@ class MSDouble(sqltypes.Float, _NumericType):
class MSReal(MSDouble):
"""MySQL REAL type."""
- def __init__(self, precision=None, length=None, asdecimal=True, **kw):
+ def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
"""Construct a REAL.
precision
- Total digits in this number. If length and precision are both None,
+ Total digits in this number. If scale and precision are both None,
values are stored to limits allowed by the server.
- length
+ scale
The number of digits after the decimal point.
unsigned
@@ -443,13 +443,13 @@ class MSReal(MSDouble):
zeros. Note that this does not effect the values returned by the
underlying database API, which continue to be numeric.
"""
- MSDouble.__init__(self, precision, length, asdecimal, **kw)
+ MSDouble.__init__(self, precision, scale, asdecimal, **kw)
def get_col_spec(self):
- if self.precision is not None and self.length is not None:
- return self._extend("REAL(%(precision)s, %(length)s)" %
+ if self.precision is not None and self.scale is not None:
+ return self._extend("REAL(%(precision)s, %(scale)s)" %
{'precision': self.precision,
- 'length' : self.length})
+ 'scale' : self.scale})
else:
return self._extend('REAL')
@@ -457,14 +457,14 @@ class MSReal(MSDouble):
class MSFloat(sqltypes.Float, _NumericType):
"""MySQL FLOAT type."""
- def __init__(self, precision=None, length=None, asdecimal=False, **kw):
+ def __init__(self, precision=None, scale=None, asdecimal=False, **kw):
"""Construct a FLOAT.
precision
- Total digits in this number. If length and precision are both None,
+ Total digits in this number. If scale and precision are both None,
values are stored to limits allowed by the server.
- length
+ scale
The number of digits after the decimal point.
unsigned
@@ -476,14 +476,14 @@ class MSFloat(sqltypes.Float, _NumericType):
underlying database API, which continue to be numeric.
"""
- _NumericType.__init__(self, **kw)
- sqltypes.Float.__init__(self, asdecimal=asdecimal)
- self.length = length
+ _NumericType.__init__(self, kw)
+ sqltypes.Float.__init__(self, asdecimal=asdecimal, **kw)
+ self.scale = scale
self.precision = precision
def get_col_spec(self):
- if self.length is not None and self.precision is not None:
- return self._extend("FLOAT(%s, %s)" % (self.precision, self.length))
+ if self.scale is not None and self.precision is not None:
+ return self._extend("FLOAT(%s, %s)" % (self.precision, self.scale))
elif self.precision is not None:
return self._extend("FLOAT(%s)" % (self.precision,))
else:
@@ -496,10 +496,10 @@ class MSFloat(sqltypes.Float, _NumericType):
class MSInteger(sqltypes.Integer, _NumericType):
"""MySQL INTEGER type."""
- def __init__(self, length=None, **kw):
+ def __init__(self, display_width=None, **kw):
"""Construct an INTEGER.
- length
+ display_width
Optional, maximum display width for this number.
unsigned
@@ -511,13 +511,17 @@ class MSInteger(sqltypes.Integer, _NumericType):
underlying database API, which continue to be numeric.
"""
- self.length = length
- _NumericType.__init__(self, **kw)
- sqltypes.Integer.__init__(self)
+ 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)
def get_col_spec(self):
- if self.length is not None:
- return self._extend("INTEGER(%(length)s)" % {'length': self.length})
+ if self.display_width is not None:
+ return self._extend("INTEGER(%(display_width)s)" % {'display_width': self.display_width})
else:
return self._extend("INTEGER")
@@ -525,10 +529,10 @@ class MSInteger(sqltypes.Integer, _NumericType):
class MSBigInteger(MSInteger):
"""MySQL BIGINTEGER type."""
- def __init__(self, length=None, **kw):
+ def __init__(self, display_width=None, **kw):
"""Construct a BIGINTEGER.
- length
+ display_width
Optional, maximum display width for this number.
unsigned
@@ -540,11 +544,11 @@ class MSBigInteger(MSInteger):
underlying database API, which continue to be numeric.
"""
- super(MSBigInteger, self).__init__(length, **kw)
+ super(MSBigInteger, self).__init__(display_width, **kw)
def get_col_spec(self):
- if self.length is not None:
- return self._extend("BIGINT(%(length)s)" % {'length': self.length})
+ if self.display_width is not None:
+ return self._extend("BIGINT(%(display_width)s)" % {'display_width': self.display_width})
else:
return self._extend("BIGINT")
@@ -552,14 +556,14 @@ class MSBigInteger(MSInteger):
class MSTinyInteger(MSInteger):
"""MySQL TINYINT type."""
- def __init__(self, length=None, **kw):
+ def __init__(self, display_width=None, **kw):
"""Construct a TINYINT.
Note: following the usual MySQL conventions, TINYINT(1) columns
reflected during Table(..., autoload=True) are treated as
Boolean columns.
- length
+ display_width
Optional, maximum display width for this number.
unsigned
@@ -571,11 +575,11 @@ class MSTinyInteger(MSInteger):
underlying database API, which continue to be numeric.
"""
- super(MSTinyInteger, self).__init__(length, **kw)
+ super(MSTinyInteger, self).__init__(display_width, **kw)
def get_col_spec(self):
- if self.length is not None:
- return self._extend("TINYINT(%s)" % self.length)
+ if self.display_width is not None:
+ return self._extend("TINYINT(%s)" % self.display_width)
else:
return self._extend("TINYINT")
@@ -583,10 +587,10 @@ class MSTinyInteger(MSInteger):
class MSSmallInteger(sqltypes.Smallinteger, MSInteger):
"""MySQL SMALLINTEGER type."""
- def __init__(self, length=None, **kw):
+ def __init__(self, display_width=None, **kw):
"""Construct a SMALLINTEGER.
- length
+ display_width
Optional, maximum display width for this number.
unsigned
@@ -598,13 +602,13 @@ class MSSmallInteger(sqltypes.Smallinteger, MSInteger):
underlying database API, which continue to be numeric.
"""
- self.length = length
- _NumericType.__init__(self, **kw)
- sqltypes.SmallInteger.__init__(self, length)
+ self.display_width = display_width
+ _NumericType.__init__(self, kw)
+ sqltypes.SmallInteger.__init__(self, **kw)
def get_col_spec(self):
- if self.length is not None:
- return self._extend("SMALLINT(%(length)s)" % {'length': self.length})
+ if self.display_width is not None:
+ return self._extend("SMALLINT(%(display_width)s)" % {'display_width': self.display_width})
else:
return self._extend("SMALLINT")
@@ -690,14 +694,14 @@ class MSTimeStamp(sqltypes.TIMESTAMP):
class MSYear(sqltypes.TypeEngine):
"""MySQL YEAR type, for single byte storage of years 1901-2155."""
- def __init__(self, length=None):
- self.length = length
+ def __init__(self, display_width=None):
+ self.display_width = display_width
def get_col_spec(self):
- if self.length is None:
+ if self.display_width is None:
return "YEAR"
else:
- return "YEAR(%s)" % self.length
+ return "YEAR(%s)" % self.display_width
class MSText(_StringType, sqltypes.Text):
"""MySQL TEXT type, for text up to 2^16 characters."""
diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py
index f2e5ba2f6..7b12e5af1 100644
--- a/lib/sqlalchemy/databases/oracle.py
+++ b/lib/sqlalchemy/databases/oracle.py
@@ -19,7 +19,7 @@ class OracleNumeric(sqltypes.Numeric):
if self.precision is None:
return "NUMERIC"
else:
- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}
class OracleInteger(sqltypes.Integer):
def get_col_spec(self):
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index 744a573c9..aeed41078 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -45,7 +45,7 @@ class PGNumeric(sqltypes.Numeric):
if not self.precision:
return "NUMERIC"
else:
- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}
def bind_processor(self, dialect):
return None
diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py
index b491ce07b..3840cb64c 100644
--- a/lib/sqlalchemy/databases/sqlite.py
+++ b/lib/sqlalchemy/databases/sqlite.py
@@ -30,7 +30,7 @@ class SLNumeric(sqltypes.Numeric):
if self.precision is None:
return "NUMERIC"
else:
- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}
class SLFloat(sqltypes.Float):
def bind_processor(self, dialect):
diff --git a/lib/sqlalchemy/databases/sybase.py b/lib/sqlalchemy/databases/sybase.py
index aea77f8bf..5c64ec1ae 100644
--- a/lib/sqlalchemy/databases/sybase.py
+++ b/lib/sqlalchemy/databases/sybase.py
@@ -168,18 +168,18 @@ class SybaseTypeError(sqltypes.TypeEngine):
class SybaseNumeric(sqltypes.Numeric):
def get_col_spec(self):
- if self.length is None:
+ if self.scale is None:
if self.precision is None:
return "NUMERIC"
else:
return "NUMERIC(%(precision)s)" % {'precision' : self.precision}
else:
- return "NUMERIC(%(precision)s, %(length)s)" % {'precision': self.precision, 'length' : self.length}
+ return "NUMERIC(%(precision)s, %(scale)s)" % {'precision': self.precision, 'scale' : self.scale}
class SybaseFloat(sqltypes.FLOAT, SybaseNumeric):
- def __init__(self, precision = 10, asdecimal = False, length = 2, **kwargs):
+ def __init__(self, precision = 10, asdecimal = False, scale = 2, **kwargs):
super(sqltypes.FLOAT, self).__init__(precision, asdecimal, **kwargs)
- self.length = length
+ self.scale = scale
def get_col_spec(self):
# if asdecimal is True, handle same way as SybaseNumeric
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py
index 3b08cf6f3..21762c663 100644
--- a/lib/sqlalchemy/types.py
+++ b/lib/sqlalchemy/types.py
@@ -450,13 +450,16 @@ Smallinteger = SmallInteger
class Numeric(TypeEngine):
"""Numeric datatype, usually resolves to DECIMAL or NUMERIC."""
- def __init__(self, precision=10, length=2, asdecimal=True):
+ 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
self.precision = precision
- self.length = length
+ self.scale = scale
self.asdecimal = asdecimal
def adapt(self, impltype):
- return impltype(precision=self.precision, length=self.length, asdecimal=self.asdecimal)
+ return impltype(precision=self.precision, scale=self.scale, asdecimal=self.asdecimal)
def get_dbapi_type(self, dbapi):
return dbapi.NUMBER
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index 443ab8878..24ac0a97e 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -380,6 +380,7 @@ def getargspec_init(method):
else:
return (['self'], 'args', 'kwargs', None)
+
def unbound_method_to_callable(func_or_cls):
"""Adjust the incoming callable such that a 'self' argument is not required."""
diff --git a/test/dialect/mysql.py b/test/dialect/mysql.py
index 415f5a653..2c944fd3a 100644
--- a/test/dialect/mysql.py
+++ b/test/dialect/mysql.py
@@ -659,7 +659,7 @@ class TypesTest(TestBase, AssertsExecutionResults):
( mysql.MSNChar(2), mysql.MSChar(2), ), # N is CREATE only
( mysql.MSNVarChar(22), mysql.MSString(22), ),
( SmallInteger(), mysql.MSSmallInteger(), ),
- ( SmallInteger(4), mysql.MSSmallInteger(4), ),
+ ( SmallInteger(), mysql.MSSmallInteger(4), ),
( mysql.MSSmallInteger(), ),
( mysql.MSSmallInteger(4), mysql.MSSmallInteger(4), ),
( Binary(3), mysql.MSBlob(3), ),
diff --git a/test/sql/functions.py b/test/sql/functions.py
index 681d6a557..27e87eceb 100644
--- a/test/sql/functions.py
+++ b/test/sql/functions.py
@@ -5,22 +5,16 @@ from sqlalchemy.sql import table, column
from sqlalchemy import databases, sql, util
from sqlalchemy.sql.compiler import BIND_TEMPLATES
from sqlalchemy.engine import default
+from testlib.engines import all_dialects
from sqlalchemy import types as sqltypes
from testlib import *
from sqlalchemy.sql.functions import GenericFunction
from testlib.testing import eq_
from sqlalchemy.databases import *
-# 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',)]
-
-# 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)
+
+# FIXME!
+dialects = [d for d in all_dialects() if d.name not in ('access', 'informix')]
class CompileTest(TestBase, AssertsCompiledSQL):
diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py
index eaeac326b..345fbceac 100644
--- a/test/sql/testtypes.py
+++ b/test/sql/testtypes.py
@@ -4,6 +4,7 @@ import datetime, os, pickleable, re
from sqlalchemy import *
from sqlalchemy import exc, types, util
from sqlalchemy.sql import operators
+from testlib.testing import eq_
import sqlalchemy.engine.url as url
from sqlalchemy.databases import mssql, oracle, mysql, postgres, firebird
from testlib import *
@@ -728,7 +729,34 @@ class NumericTest(TestBase, AssertsExecutionResults):
assert isinstance(row['ncasdec'], decimal.Decimal)
assert isinstance(row['fcasdec'], decimal.Decimal)
-
+ 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()
+
+
class IntervalTest(TestBase, AssertsExecutionResults):
def setUpAll(self):
global interval_table, metadata
diff --git a/test/testlib/engines.py b/test/testlib/engines.py
index 3df98d4fc..a6e9fb8b7 100644
--- a/test/testlib/engines.py
+++ b/test/testlib/engines.py
@@ -66,6 +66,12 @@ def close_open_connections(fn):
testing_reaper.close_all()
return _function_named(decorated, fn.__name__)
+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()
+
class ReconnectFixture(object):
def __init__(self, dbapi):
self.dbapi = dbapi