summaryrefslogtreecommitdiff
path: root/test/dialect/test_postgresql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-11-01 22:47:14 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-11-01 22:47:14 +0000
commite8854fe945e94d0fe654e83397c47f8b0fb1f1e8 (patch)
treebb6b4b9c09a476cb859fcdbc29863e5872ec3fc1 /test/dialect/test_postgresql.py
parentfb6be4d35906ccc822634a7657ec109b5d8cbb7f (diff)
downloadsqlalchemy-e8854fe945e94d0fe654e83397c47f8b0fb1f1e8.tar.gz
- INTERVAL supports an optional "precision" argument
corresponding to the argument that PG accepts. - Added support for reflecting the INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND syntaxes of the INTERVAL type. [ticket:460]
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r--test/dialect/test_postgresql.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py
index e4a5ffa55..aa2b99275 100644
--- a/test/dialect/test_postgresql.py
+++ b/test/dialect/test_postgresql.py
@@ -4,7 +4,7 @@ from sqlalchemy.test import engines
import datetime
from sqlalchemy import *
from sqlalchemy.orm import *
-from sqlalchemy import exc, schema
+from sqlalchemy import exc, schema, types
from sqlalchemy.dialects.postgresql import base as postgresql
from sqlalchemy.engine.strategies import MockEngineStrategy
from sqlalchemy.test import *
@@ -1320,17 +1320,35 @@ class SpecialTypesTest(TestBase, ComparesTables):
global metadata, table
metadata = MetaData(testing.db)
+ # create these types so that we can issue
+ # special SQL92 INTERVAL syntax
+ class y2m(types.UserDefinedType, postgresql.INTERVAL):
+ def get_col_spec(self):
+ return "INTERVAL YEAR TO MONTH"
+
+ class d2s(types.UserDefinedType, postgresql.INTERVAL):
+ def get_col_spec(self):
+ return "INTERVAL DAY TO SECOND"
+
table = Table('sometable', metadata,
Column('id', postgresql.PGUuid, primary_key=True),
Column('flag', postgresql.PGBit),
Column('addr', postgresql.PGInet),
Column('addr2', postgresql.PGMacAddr),
Column('addr3', postgresql.PGCidr),
- Column('doubleprec', postgresql.DOUBLE_PRECISION)
-
+ Column('doubleprec', postgresql.DOUBLE_PRECISION),
+ Column('plain_interval', postgresql.INTERVAL),
+ Column('year_interval', y2m()),
+ Column('month_interval', d2s()),
+ Column('precision_interval', postgresql.INTERVAL(precision=3))
)
metadata.create_all()
+
+ # cheat so that the "strict type check"
+ # works
+ table.c.year_interval.type = postgresql.INTERVAL()
+ table.c.month_interval.type = postgresql.INTERVAL()
@classmethod
def teardown_class(cls):
@@ -1341,7 +1359,8 @@ class SpecialTypesTest(TestBase, ComparesTables):
t = Table('sometable', m, autoload=True)
self.assert_tables_equal(table, t, strict_types=True)
-
+ assert t.c.plain_interval.type.precision is None
+ assert t.c.precision_interval.type.precision == 3
class MatchTest(TestBase, AssertsCompiledSQL):
__only_on__ = 'postgresql'