Kaydet (Commit) 87a8046f authored tarafından Ian Kelly's avatar Ian Kelly

Made the oracle backend throw the same ValueError as the mysql backend when a…

Made the oracle backend throw the same ValueError as the mysql backend 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
üst e0e347c2
......@@ -292,11 +292,24 @@ WHEN (new.%(col_name)s IS NULL)
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)
......
......@@ -76,8 +76,8 @@ class DataTypesTestCase(TestCase):
@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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment