Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made the oracle backend throw the same ValueError as the mysql backen…

…d when a timezone-aware datetime is passed in. This fixes a datatypes test failure.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14544 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 87a8046f9030646adec583c34597a1f634a0d11b 1 parent e0e347c
Ian Kelly ikelly authored
13 django/db/backends/oracle/base.py
View
@@ -292,11 +292,24 @@ def tablespace_sql(self, tablespace, inline=False):
return "%sTABLESPACE %s" % ((inline and "USING INDEX " or ""),
self.quote_name(tablespace))
+ def value_to_db_datetime(self, value):
+ # Oracle doesn't support tz-aware datetimes
+ if getattr(value, 'tzinfo', None) is not None:
+ raise ValueError("Oracle backend does not support timezone-aware datetimes.")
+
+ return super(DatabaseOperations, self).value_to_db_datetime(value)
+
def value_to_db_time(self, value):
if value is None:
return None
+
if isinstance(value, basestring):
return datetime.datetime(*(time.strptime(value, '%H:%M:%S')[:6]))
+
+ # Oracle doesn't support tz-aware datetimes
+ if value.tzinfo is not None:
+ raise ValueError("Oracle backend does not support timezone-aware datetimes.")
+
return datetime.datetime(1900, 1, 1, value.hour, value.minute,
value.second, value.microsecond)
4 tests/regressiontests/datatypes/tests.py
View
@@ -76,8 +76,8 @@ def test_textfields_unicode(self):
@skipIfDBFeature('supports_timezones')
def test_error_on_timezone(self):
- """Regression test for #8354: the MySQL backend should raise an error
- if given a timezone-aware datetime object."""
+ """Regression test for #8354: the MySQL and Oracle backends should raise
+ an error if given a timezone-aware datetime object."""
dt = datetime.datetime(2008, 8, 31, 16, 20, tzinfo=tzinfo.FixedOffset(0))
d = Donut(name='Bear claw', consumed_at=dt)
self.assertRaises(ValueError, d.save)
Please sign in to comment.
Something went wrong with that request. Please try again.