From 34cb747f647747fc1685156d28166ab33da81ae8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 18 Nov 2010 18:10:03 -0500 Subject: - Ensured every numeric, float, int code, scalar + array, are recognized by psycopg2 and pg8000's "numeric" base type. [ticket:1955] --- test/dialect/test_postgresql.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/dialect/test_postgresql.py') diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index e20274aef..54127cd98 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -456,7 +456,25 @@ class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): assert t2.c.value2.type.schema == 'test_schema' finally: metadata.drop_all() + +class NumericInterpretationTest(TestBase): + + + def test_numeric_codes(self): + from sqlalchemy.dialects.postgresql import pg8000, psycopg2, base + from decimal import Decimal + for dialect in (pg8000.dialect(), psycopg2.dialect()): + + typ = Numeric().dialect_impl(dialect) + for code in base._INT_TYPES + base._FLOAT_TYPES + \ + base._DECIMAL_TYPES: + proc = typ.result_processor(dialect, code) + val = 23.7 + if proc is not None: + val = proc(val) + assert val in (23.7, Decimal("23.7")) + class InsertTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgresql' -- cgit v1.2.1