Fixed #20292: Pass datetime objects (not formatted dates) as params to Oracle

This seems worthwhile in its own right, but also works around an Oracle
bug (in versions 10 -- 11.1) where the use of Unicode would reset the
date/time formats, causing ORA-01843 errors.

Thanks Trac users CarstenF for the report, jtiai for the initial patch,
and everyone who contributed to the discussion on the ticket.
This commit is contained in:
Shai Berger 2014-03-12 23:43:45 +02:00
parent fc79c3fb3d
commit 6983201cfb
3 changed files with 63 additions and 17 deletions

View file

@ -23,7 +23,7 @@ from django.utils.functional import lazy
from .models import (
Foo, Bar, Whiz, BigD, BigS, BigInt, Post, NullBooleanModel,
BooleanModel, PrimaryKeyCharModel, DataModel, Document, RenamedField,
VerboseNameField, FksToBooleans, FkToChar, FloatModel)
DateTimeModel, VerboseNameField, FksToBooleans, FkToChar, FloatModel)
class BasicFieldTests(test.TestCase):
@ -197,6 +197,17 @@ class DateTimeFieldTests(unittest.TestCase):
self.assertEqual(f.to_python('01:02:03.999999'),
datetime.time(1, 2, 3, 999999))
def test_datetimes_save_completely(self):
dat = datetime.date(2014, 3, 12)
datetim = datetime.datetime(2014, 3, 12, 21, 22, 23, 240000)
tim = datetime.time(21, 22, 23, 240000)
DateTimeModel.objects.create(d=dat, dt=datetim, t=tim)
obj = DateTimeModel.objects.first()
self.assertTrue(obj)
self.assertEqual(obj.d, dat)
self.assertEqual(obj.dt, datetim)
self.assertEqual(obj.t, tim)
class BooleanFieldTests(unittest.TestCase):
def _test_get_db_prep_lookup(self, f):