summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/access/base.py5
-rw-r--r--lib/sqlalchemy/dialects/maxdb/base.py10
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py39
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py20
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py4
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py34
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py3
7 files changed, 45 insertions, 70 deletions
diff --git a/lib/sqlalchemy/dialects/access/base.py b/lib/sqlalchemy/dialects/access/base.py
index 75ea91287..cf35b3e0a 100644
--- a/lib/sqlalchemy/dialects/access/base.py
+++ b/lib/sqlalchemy/dialects/access/base.py
@@ -50,15 +50,10 @@ class AcSmallInteger(types.SmallInteger):
return "SMALLINT"
class AcDateTime(types.DateTime):
- def __init__(self, *a, **kw):
- super(AcDateTime, self).__init__(False)
-
def get_col_spec(self):
return "DATETIME"
class AcDate(types.Date):
- def __init__(self, *a, **kw):
- super(AcDate, self).__init__(False)
def get_col_spec(self):
return "DATETIME"
diff --git a/lib/sqlalchemy/dialects/maxdb/base.py b/lib/sqlalchemy/dialects/maxdb/base.py
index 9a1e10f51..3d45bb670 100644
--- a/lib/sqlalchemy/dialects/maxdb/base.py
+++ b/lib/sqlalchemy/dialects/maxdb/base.py
@@ -116,15 +116,13 @@ class _StringType(sqltypes.String):
class MaxString(_StringType):
_type = 'VARCHAR'
- def __init__(self, *a, **kw):
- super(MaxString, self).__init__(*a, **kw)
-
class MaxUnicode(_StringType):
_type = 'VARCHAR'
def __init__(self, length=None, **kw):
- super(MaxUnicode, self).__init__(length=length, encoding='unicode')
+ kw['encoding'] = 'unicode'
+ super(MaxUnicode, self).__init__(length=length, **kw)
class MaxChar(_StringType):
@@ -134,8 +132,8 @@ class MaxChar(_StringType):
class MaxText(_StringType):
_type = 'LONG'
- def __init__(self, *a, **kw):
- super(MaxText, self).__init__(*a, **kw)
+ def __init__(self, length=None, **kw):
+ super(MaxText, self).__init__(length, **kw)
def get_col_spec(self):
spec = 'LONG'
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index b1fb46041..028322677 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -175,8 +175,9 @@ class REAL(sqltypes.Float):
__visit_name__ = 'REAL'
- def __init__(self):
- super(REAL, self).__init__(precision=24)
+ def __init__(self, **kw):
+ kw.setdefault('precision', 24)
+ super(REAL, self).__init__(**kw)
class TINYINT(sqltypes.Integer):
__visit_name__ = 'TINYINT'
@@ -258,7 +259,8 @@ class SMALLDATETIME(_DateTimeBase, sqltypes.DateTime):
class DATETIME2(_DateTimeBase, sqltypes.DateTime):
__visit_name__ = 'DATETIME2'
- def __init__(self, precision=None, **kwargs):
+ def __init__(self, precision=None, **kw):
+ super(DATETIME2, self).__init__(**kw)
self.precision = precision
@@ -278,16 +280,15 @@ class _StringType(object):
class TEXT(_StringType, sqltypes.TEXT):
"""MSSQL TEXT type, for variable-length text up to 2^31 characters."""
- def __init__(self, *args, **kw):
+ def __init__(self, length=None, collation=None, **kw):
"""Construct a TEXT.
:param collation: Optional, a column-level collation for this string
value. Accepts a Windows Collation Name or a SQL Collation Name.
"""
- collation = kw.pop('collation', None)
_StringType.__init__(self, collation)
- sqltypes.Text.__init__(self, *args, **kw)
+ sqltypes.Text.__init__(self, length, **kw)
class NTEXT(_StringType, sqltypes.UnicodeText):
"""MSSQL NTEXT type, for variable-length unicode text up to 2^30
@@ -295,24 +296,22 @@ class NTEXT(_StringType, sqltypes.UnicodeText):
__visit_name__ = 'NTEXT'
- def __init__(self, *args, **kwargs):
+ def __init__(self, length=None, collation=None, **kw):
"""Construct a NTEXT.
:param collation: Optional, a column-level collation for this string
value. Accepts a Windows Collation Name or a SQL Collation Name.
"""
- collation = kwargs.pop('collation', None)
_StringType.__init__(self, collation)
- length = kwargs.pop('length', None)
- sqltypes.UnicodeText.__init__(self, length, **kwargs)
+ sqltypes.UnicodeText.__init__(self, length, **kw)
class VARCHAR(_StringType, sqltypes.VARCHAR):
"""MSSQL VARCHAR type, for variable-length non-Unicode data with a maximum
of 8,000 characters."""
- def __init__(self, *args, **kw):
+ def __init__(self, length=None, collation=None, **kw):
"""Construct a VARCHAR.
:param length: Optinal, maximum data length, in characters.
@@ -333,16 +332,15 @@ class VARCHAR(_StringType, sqltypes.VARCHAR):
value. Accepts a Windows Collation Name or a SQL Collation Name.
"""
- collation = kw.pop('collation', None)
_StringType.__init__(self, collation)
- sqltypes.VARCHAR.__init__(self, *args, **kw)
+ sqltypes.VARCHAR.__init__(self, length, **kw)
class NVARCHAR(_StringType, sqltypes.NVARCHAR):
"""MSSQL NVARCHAR type.
For variable-length unicode character data up to 4,000 characters."""
- def __init__(self, *args, **kw):
+ def __init__(self, length=None, collation=None, **kw):
"""Construct a NVARCHAR.
:param length: Optional, Maximum data length, in characters.
@@ -351,15 +349,14 @@ class NVARCHAR(_StringType, sqltypes.NVARCHAR):
value. Accepts a Windows Collation Name or a SQL Collation Name.
"""
- collation = kw.pop('collation', None)
_StringType.__init__(self, collation)
- sqltypes.NVARCHAR.__init__(self, *args, **kw)
+ sqltypes.NVARCHAR.__init__(self, length, **kw)
class CHAR(_StringType, sqltypes.CHAR):
"""MSSQL CHAR type, for fixed-length non-Unicode data with a maximum
of 8,000 characters."""
- def __init__(self, *args, **kw):
+ def __init__(self, length=None, collation=None, **kw):
"""Construct a CHAR.
:param length: Optinal, maximum data length, in characters.
@@ -380,16 +377,15 @@ class CHAR(_StringType, sqltypes.CHAR):
value. Accepts a Windows Collation Name or a SQL Collation Name.
"""
- collation = kw.pop('collation', None)
_StringType.__init__(self, collation)
- sqltypes.CHAR.__init__(self, *args, **kw)
+ sqltypes.CHAR.__init__(self, length, **kw)
class NCHAR(_StringType, sqltypes.NCHAR):
"""MSSQL NCHAR type.
For fixed-length unicode character data up to 4,000 characters."""
- def __init__(self, *args, **kw):
+ def __init__(self, length=None, collation=None, **kw):
"""Construct an NCHAR.
:param length: Optional, Maximum data length, in characters.
@@ -398,9 +394,8 @@ class NCHAR(_StringType, sqltypes.NCHAR):
value. Accepts a Windows Collation Name or a SQL Collation Name.
"""
- collation = kw.pop('collation', None)
_StringType.__init__(self, collation)
- sqltypes.NCHAR.__init__(self, *args, **kw)
+ sqltypes.NCHAR.__init__(self, length, **kw)
class IMAGE(sqltypes.LargeBinary):
__visit_name__ = 'IMAGE'
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 42072699e..528e94965 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -233,11 +233,11 @@ SET_RE = re.compile(
class _NumericType(object):
"""Base for MySQL numeric types."""
- def __init__(self, **kw):
- self.unsigned = kw.pop('unsigned', False)
- self.zerofill = kw.pop('zerofill', False)
+ def __init__(self, unsigned=False, zerofill=False, **kw):
+ self.unsigned = unsigned
+ self.zerofill = zerofill
super(_NumericType, self).__init__(**kw)
-
+
class _FloatType(_NumericType, sqltypes.Float):
def __init__(self, precision=None, scale=None, asdecimal=True, **kw):
if isinstance(self, (REAL, DOUBLE)) and \
@@ -276,7 +276,7 @@ class _StringType(sqltypes.String):
self.binary = binary
self.national = national
super(_StringType, self).__init__(**kw)
-
+
def __repr__(self):
attributes = inspect.getargspec(self.__init__)[0][1:]
attributes.extend(inspect.getargspec(_StringType.__init__)[0][1:])
@@ -749,7 +749,7 @@ class CHAR(_StringType, sqltypes.CHAR):
__visit_name__ = 'CHAR'
- def __init__(self, length, **kwargs):
+ def __init__(self, length=None, **kwargs):
"""Construct a CHAR.
:param length: Maximum data length, in characters.
@@ -943,6 +943,10 @@ class ENUM(sqltypes.Enum, _StringType):
else:
return value
return process
+
+ def adapt(self, impltype, **kw):
+ kw['strict'] = self.strict
+ return sqltypes.Enum.adapt(self, impltype, **kw)
class SET(_StringType):
"""MySQL SET type."""
@@ -990,8 +994,8 @@ class SET(_StringType):
strip_values.append(a)
self.values = strip_values
- length = max([len(v) for v in strip_values] + [0])
- super(SET, self).__init__(length=length, **kw)
+ kw.setdefault('length', max([len(v) for v in strip_values] + [0]))
+ super(SET, self).__init__(**kw)
def result_processor(self, dialect, coltype):
def process(value):
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index 256972696..3d97b504e 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -215,10 +215,6 @@ class INTERVAL(sqltypes.TypeEngine):
return INTERVAL(day_precision=interval.day_precision,
second_precision=interval.second_precision)
- def adapt(self, impltype):
- return impltype(day_precision=self.day_precision,
- second_precision=self.second_precision)
-
@property
def _type_affinity(self):
return sqltypes.Interval
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 821ec5cfb..72b58a71c 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -132,12 +132,13 @@ class TIMESTAMP(sqltypes.TIMESTAMP):
def __init__(self, timezone=False, precision=None):
super(TIMESTAMP, self).__init__(timezone=timezone)
self.precision = precision
+
class TIME(sqltypes.TIME):
def __init__(self, timezone=False, precision=None):
super(TIME, self).__init__(timezone=timezone)
self.precision = precision
-
+
class INTERVAL(sqltypes.TypeEngine):
"""Postgresql INTERVAL type.
@@ -149,9 +150,6 @@ class INTERVAL(sqltypes.TypeEngine):
def __init__(self, precision=None):
self.precision = precision
- def adapt(self, impltype):
- return impltype(self.precision)
-
@classmethod
def _adapt_from_generic_interval(cls, interval):
return INTERVAL(precision=interval.second_precision)
@@ -164,6 +162,9 @@ PGInterval = INTERVAL
class BIT(sqltypes.TypeEngine):
__visit_name__ = 'BIT'
+ def __init__(self, length=1):
+ self.length= length
+
PGBit = BIT
class UUID(sqltypes.TypeEngine):
@@ -213,7 +214,7 @@ class UUID(sqltypes.TypeEngine):
return process
else:
return None
-
+
PGUuid = UUID
class ARRAY(sqltypes.MutableType, sqltypes.Concatenable, sqltypes.TypeEngine):
@@ -285,23 +286,8 @@ class ARRAY(sqltypes.MutableType, sqltypes.Concatenable, sqltypes.TypeEngine):
def is_mutable(self):
return self.mutable
- def dialect_impl(self, dialect, **kwargs):
- impl = super(ARRAY, self).dialect_impl(dialect, **kwargs)
- if impl is self:
- impl = self.__class__.__new__(self.__class__)
- impl.__dict__.update(self.__dict__)
- impl.item_type = self.item_type.dialect_impl(dialect)
- return impl
-
- def adapt(self, impltype):
- return impltype(
- self.item_type,
- mutable=self.mutable,
- as_tuple=self.as_tuple
- )
-
def bind_processor(self, dialect):
- item_proc = self.item_type.bind_processor(dialect)
+ item_proc = self.item_type.dialect_impl(dialect).bind_processor(dialect)
if item_proc:
def convert_item(item):
if isinstance(item, (list, tuple)):
@@ -321,7 +307,7 @@ class ARRAY(sqltypes.MutableType, sqltypes.Concatenable, sqltypes.TypeEngine):
return process
def result_processor(self, dialect, coltype):
- item_proc = self.item_type.result_processor(dialect, coltype)
+ item_proc = self.item_type.dialect_impl(dialect).result_processor(dialect, coltype)
if item_proc:
def convert_item(item):
if isinstance(item, list):
@@ -640,7 +626,7 @@ class PGTypeCompiler(compiler.GenericTypeCompiler):
return "INTERVAL"
def visit_BIT(self, type_):
- return "BIT"
+ return "BIT(%d)" % type_.length
def visit_UUID(self, type_):
return "UUID"
@@ -1095,7 +1081,7 @@ class PGDialect(default.DefaultDialect):
elif attype == 'double precision':
args = (53, )
elif attype == 'integer':
- args = (32, 0)
+ args = ()
elif attype in ('timestamp with time zone',
'time with time zone'):
kwargs['timezone'] = True
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index 707bc1630..1ab5173fe 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -72,7 +72,8 @@ class _DateTimeMixin(object):
_reg = None
_storage_format = None
- def __init__(self, storage_format=None, regexp=None, **kwargs):
+ def __init__(self, storage_format=None, regexp=None, **kw):
+ super(_DateTimeMixin, self).__init__(**kw)
if regexp is not None:
self._reg = re.compile(regexp)
if storage_format is not None: