diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/pg8000.py | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/psycopg2.py | 10 | ||||
| -rw-r--r-- | lib/sqlalchemy/test/testing.py | 17 |
3 files changed, 26 insertions, 9 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index a620daac6..c822e37a5 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -31,18 +31,18 @@ from sqlalchemy.dialects.postgresql.base import PGDialect, \ class _PGNumeric(sqltypes.Numeric): def result_processor(self, dialect, coltype): if self.asdecimal: - if coltype in (700, 701): + if coltype in (700, 701, 1021, 1022): return processors.to_decimal_processor_factory(decimal.Decimal) - elif coltype == 1700: + elif coltype in (1700, 1231): # pg8000 returns Decimal natively for 1700 return None else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) else: - if coltype in (700, 701): + if coltype in (700, 701, 1021, 1022): # pg8000 returns float natively for 701 return None - elif coltype == 1700: + elif coltype in (1700, 1231): return processors.to_float else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index f21c9a558..45d1bf29e 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -60,7 +60,7 @@ import re import decimal import logging -from sqlalchemy import util +from sqlalchemy import util, exc from sqlalchemy import processors from sqlalchemy.engine import base, default from sqlalchemy.sql import expression @@ -80,18 +80,18 @@ class _PGNumeric(sqltypes.Numeric): def result_processor(self, dialect, coltype): if self.asdecimal: - if coltype in (700, 701): + if coltype in (700, 701, 1021, 1022): return processors.to_decimal_processor_factory(decimal.Decimal) - elif coltype == 1700: + elif coltype in (1700, 1231): # pg8000 returns Decimal natively for 1700 return None else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) else: - if coltype in (700, 701): + if coltype in (700, 701, 1021, 1022): # pg8000 returns float natively for 701 return None - elif coltype == 1700: + elif coltype in (1700, 1231): return processors.to_float else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) diff --git a/lib/sqlalchemy/test/testing.py b/lib/sqlalchemy/test/testing.py index 771b8c90f..70ddc7ba2 100644 --- a/lib/sqlalchemy/test/testing.py +++ b/lib/sqlalchemy/test/testing.py @@ -546,6 +546,23 @@ def fixture(table, columns, *rows): for column_values in rows]) table.append_ddl_listener('after-create', onload) +def provide_metadata(fn): + """Provides a bound MetaData object for a single test, + drops it afterwards.""" + def maybe(*args, **kw): + metadata = schema.MetaData(db) + context = dict(fn.func_globals) + context['metadata'] = metadata + # jython bug #1034 + rebound = types.FunctionType( + fn.func_code, context, fn.func_name, fn.func_defaults, + fn.func_closure) + try: + return rebound(*args, **kw) + finally: + metadata.drop_all() + return function_named(maybe, fn.__name__) + def resolve_artifact_names(fn): """Decorator, augment function globals with tables and classes. |
