summaryrefslogtreecommitdiff
path: root/test/dialect/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-07 16:07:55 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-07 16:07:55 -0400
commit3351b65df94324b2baba87da303c9db3454653d6 (patch)
treeea5e43a5f6360db8a696379e3bced3fc7208fe58 /test/dialect/test_postgresql.py
parent8842bbd8b5e72796926b6e35f86d060c3b86b6a2 (diff)
downloadsqlalchemy-3351b65df94324b2baba87da303c9db3454653d6.tar.gz
- Repaired missing import in psycopg2._PGNumeric type when
unknown numeric is received. - psycopg2/pg8000 dialects now aware of REAL[], FLOAT[], DOUBLE_PRECISION[], NUMERIC[] return types without raising an exception. - introducing testing.provide_metadata for all these stupid little create/drop tests
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r--test/dialect/test_postgresql.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py
index fbe62cdec..bcf8ac956 100644
--- a/test/dialect/test_postgresql.py
+++ b/test/dialect/test_postgresql.py
@@ -228,7 +228,21 @@ class FloatCoercionTest(TablesTest, AssertsExecutionResults):
).scalar()
eq_(round_decimal(ret, 9), result)
-
+ @testing.provide_metadata
+ def test_arrays(self):
+ t1 = Table('t', metadata,
+ Column('x', postgresql.ARRAY(Float)),
+ Column('y', postgresql.ARRAY(postgresql.REAL)),
+ Column('z', postgresql.ARRAY(postgresql.DOUBLE_PRECISION)),
+ Column('q', postgresql.ARRAY(Numeric))
+ )
+ metadata.create_all()
+ t1.insert().execute(x=[5], y=[5], z=[6], q=[6.4])
+ row = t1.select().execute().first()
+ eq_(
+ row,
+ ([5], [5], [6], [decimal.Decimal("6.4")])
+ )
class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
__only_on__ = 'postgresql'
@@ -1311,8 +1325,17 @@ class MiscTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
else:
exception_cls = eng.dialect.dbapi.ProgrammingError
assert_raises(exception_cls, eng.execute, "show transaction isolation level")
-
-
+
+ @testing.only_on('postgresql+psycopg2',
+ "this assertion isn't used on others, "
+ "except pg8000 which circumvents it")
+ def test_numeric_raise(self):
+ stmt = text("select 'hi' as hi", typemap={'hi':Numeric})
+ assert_raises(
+ exc.InvalidRequestError,
+ testing.db.execute, stmt
+ )
+
class TimezoneTest(TestBase):
"""Test timezone-aware datetimes.