1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

boulder-oracle-sprint: Fixed TimeField.get_db_prep_lookup to include a dummy date in the time string so that Oracle doesn't barf on it.

git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5007 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters 2007-04-13 20:40:22 +00:00
parent 48c0460605
commit 531235c3bf

View File

@ -830,10 +830,15 @@ class TimeField(Field):
Field.__init__(self, verbose_name, name, **kwargs)
def get_db_prep_lookup(self, lookup_type, value):
def prep(value):
if settings.DATABASE_ENGINE == 'oracle' and isinstance(value, datetime.time):
# Oracle requires a date in order to parse.
value = datetime.datetime.combine(datetime.date(1900, 1, 1), value)
return str(value)
if lookup_type == 'range':
value = [str(v) for v in value]
value = [prep(v) for v in value]
else:
value = str(value)
value = prep(value)
return Field.get_db_prep_lookup(self, lookup_type, value)
def pre_save(self, model_instance, add):