diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-05-20 17:05:14 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-05-20 17:05:14 +0100 |
commit | 6a3521badb80d4cb8d4091796b442a9843496134 (patch) | |
tree | 57ecbe6a2510dd95c0a50a383dc2a0db04d5f3f2 | |
parent | 42efb739d8610a1f11840002f7def545e165ace7 (diff) | |
parent | f2896fe51289e4e73e296ab137713e586a4f8610 (diff) | |
download | psycopg2-6a3521badb80d4cb8d4091796b442a9843496134.tar.gz |
Merge branch 'fix-707' into maint_2_7
-rw-r--r-- | psycopg/typecast_datetime.c | 5 | ||||
-rwxr-xr-x | tests/test_dates.py | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/psycopg/typecast_datetime.c b/psycopg/typecast_datetime.c index f24223c..e34117d 100644 --- a/psycopg/typecast_datetime.c +++ b/psycopg/typecast_datetime.c @@ -406,6 +406,11 @@ typecast_PYINTERVAL_cast(const char *str, Py_ssize_t len, PyObject *curs) } break; + case 'P': + PyErr_SetString(NotSupportedError, + "iso_8601 intervalstyle currently not supported"); + return NULL; + default: break; } diff --git a/tests/test_dates.py b/tests/test_dates.py index df088ee..498d09a 100755 --- a/tests/test_dates.py +++ b/tests/test_dates.py @@ -437,6 +437,14 @@ class DatetimeTests(ConnectingTestCase, CommonDatetimeTestsMixin): r = cur.fetchone()[0] self.assertEqual(r, v, "%s -> %s != %s" % (s, r, v)) + @skip_before_postgres(8, 4) + def test_interval_iso_8601_not_supported(self): + # We may end up supporting, but no pressure for it + cur = self.conn.cursor() + cur.execute("set local intervalstyle to iso_8601") + cur.execute("select '1 day 2 hours'::interval") + self.assertRaises(psycopg2.NotSupportedError, cur.fetchone) + # Only run the datetime tests if psycopg was compiled with support. if not hasattr(psycopg2.extensions, 'PYDATETIME'): |