From d61a48ccfd1024b744c003d354cd95b136d41a43 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 9 Apr 2010 13:01:17 -0400 Subject: - fixed numeric test for pg8000, factored out decimal/float codes --- lib/sqlalchemy/dialects/postgresql/pg8000.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy/dialects/postgresql/pg8000.py') diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index c822e37a5..862c915aa 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -26,23 +26,24 @@ from sqlalchemy import util, exc from sqlalchemy import processors from sqlalchemy import types as sqltypes from sqlalchemy.dialects.postgresql.base import PGDialect, \ - PGCompiler, PGIdentifierPreparer, PGExecutionContext + PGCompiler, PGIdentifierPreparer, PGExecutionContext,\ + _DECIMAL_TYPES, _FLOAT_TYPES class _PGNumeric(sqltypes.Numeric): def result_processor(self, dialect, coltype): if self.asdecimal: - if coltype in (700, 701, 1021, 1022): + if coltype in _FLOAT_TYPES: return processors.to_decimal_processor_factory(decimal.Decimal) - elif coltype in (1700, 1231): + elif coltype in _DECIMAL_TYPES: # pg8000 returns Decimal natively for 1700 return None else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) else: - if coltype in (700, 701, 1021, 1022): + if coltype in _FLOAT_TYPES: # pg8000 returns float natively for 701 return None - elif coltype in (1700, 1231): + elif coltype in _DECIMAL_TYPES: return processors.to_float else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) -- cgit v1.2.1