summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-11-19 15:10:46 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-11-19 15:11:37 -0500
commit9ed36c2eed34b23560abe3cdf373c720b24d3b30 (patch)
treee387738957531c49c24745158884847ee837ee83 /test
parentc7f9aa281857eeeaf7963c370bda43d2eb4746f5 (diff)
downloadsqlalchemy-9ed36c2eed34b23560abe3cdf373c720b24d3b30.tar.gz
- Fixed the ``.python_type`` attribute of :class:`.postgresql.INTERVAL`
to return ``datetime.timedelta`` in the same way as that of :obj:`.types.Interval.python_type`, rather than raising ``NotImplementedError``. fixes #3571 (cherry picked from commit 29d6f6e19b014bb5ce79032bd8803e32b4da0e5e)
Diffstat (limited to 'test')
-rw-r--r--test/dialect/postgresql/test_types.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index 6ed90c76d..49a8cfabd 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -589,6 +589,14 @@ class NumericInterpretationTest(fixtures.TestBase):
)
+class PythonTypeTest(fixtures.TestBase):
+ def test_interval(self):
+ is_(
+ postgresql.INTERVAL().python_type,
+ datetime.timedelta
+ )
+
+
class TimezoneTest(fixtures.TestBase):
__backend__ = True
@@ -1419,6 +1427,16 @@ class TimestampTest(fixtures.TestBase, AssertsExecutionResults):
result = connection.execute(s).first()
eq_(result[0], datetime.datetime(2007, 12, 25, 0, 0))
+ def test_interval_arithmetic(self):
+ # basically testing that we get timedelta back for an INTERVAL
+ # result. more of a driver assertion.
+ engine = testing.db
+ connection = engine.connect()
+
+ s = select([text("timestamp '2007-12-25' - timestamp '2007-11-15'")])
+ result = connection.execute(s).first()
+ eq_(result[0], datetime.timedelta(40))
+
class SpecialTypesTest(fixtures.TestBase, ComparesTables, AssertsCompiledSQL):