From 75b5236e69b4607d549d466bd34d409f3cc9ed45 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 15 Jan 2011 11:53:37 -0500 Subject: - the _pk_processors/_prefetch_processors approach relied upon calling RPs without a cursor.description result, also generates procs that are not used in most cases. simplify the approach by passing type to _exec_default() to be used if needed by _execute_scalar(), looking for the proc on just t._autoincrement_column in post_insert(). --- test/dialect/test_postgresql.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'test/dialect/test_postgresql.py') diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index a8c63c566..fb5a63c9b 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -476,7 +476,7 @@ class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): metadata.drop_all() class NumericInterpretationTest(TestBase): - + __only_on__ = 'postgresql' def test_numeric_codes(self): from sqlalchemy.dialects.postgresql import pg8000, psycopg2, base @@ -493,6 +493,28 @@ class NumericInterpretationTest(TestBase): val = proc(val) assert val in (23.7, decimal.Decimal("23.7")) + @testing.provide_metadata + def test_numeric_default(self): + t =Table('t', metadata, + Column('id', Integer, primary_key=True), + Column('nd', Numeric(asdecimal=True), default=0), + Column('nf', Numeric(asdecimal=False), default=0), + Column('fd', Float(asdecimal=True), default=0), + Column('ff', Float(asdecimal=False), default=0), + ) + metadata.create_all() + r = t.insert().execute() + + row = t.select().execute().first() + assert isinstance(row[1], decimal.Decimal) + assert isinstance(row[2], float) + assert isinstance(row[3], decimal.Decimal) + assert isinstance(row[4], float) + eq_( + row, + (1, decimal.Decimal("0"), 0, decimal.Decimal("0"), 0) + ) + class InsertTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgresql' -- cgit v1.2.1