diff options
author | Michael Trier <mtrier@gmail.com> | 2010-12-19 19:38:03 -0500 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2010-12-19 19:38:03 -0500 |
commit | 650bbcc8fd404b2122f1f5ab10eadb4fe3837274 (patch) | |
tree | 52755cef4e4cf4274681dc385c6d96e4113dadf2 /lib/sqlalchemy/dialects/postgresql | |
parent | 15ea17d7f882fec3f892a22612da4827780c8dae (diff) | |
parent | 0a46523a92dbf5229575cd75bb1be989024676ec (diff) | |
download | sqlalchemy-650bbcc8fd404b2122f1f5ab10eadb4fe3837274.tar.gz |
merge tip
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 34 |
1 files changed, 10 insertions, 24 deletions
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 |