mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
queryset-refactor: Pass any extra(select=...) columns through the value
conversion function in the Oracle backend after reading the row from the database. Refs #7087 (see comment 7 on that ticket). git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7470 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3933aff6cc
commit
0b30bed861
@ -29,8 +29,12 @@ def query_class(QueryClass, Database):
|
||||
from django.db.models.fields import DateField, DateTimeField, \
|
||||
TimeField, BooleanField, NullBooleanField, DecimalField, Field
|
||||
index_start = len(self.extra_select.keys())
|
||||
values = list(row[:index_start])
|
||||
values = [self.convert_values(v, None) for v in row[:index_start]]
|
||||
for value, field in map(None, row[index_start:], fields):
|
||||
values.append(self.convert_values(value, field))
|
||||
return values
|
||||
|
||||
def convert_values(self, value, field):
|
||||
if isinstance(value, Database.LOB):
|
||||
value = value.read()
|
||||
# Oracle stores empty strings as null. We need to undo this in
|
||||
@ -59,18 +63,20 @@ def query_class(QueryClass, Database):
|
||||
# In Python 2.3, the cx_Oracle driver returns its own
|
||||
# Timestamp object that we must convert to a datetime class.
|
||||
if not isinstance(value, datetime.datetime):
|
||||
value = datetime.datetime(value.year, value.month, value.day, value.hour,
|
||||
value.minute, value.second, value.fsecond)
|
||||
value = datetime.datetime(value.year, value.month,
|
||||
value.day, value.hour, value.minute, value.second,
|
||||
value.fsecond)
|
||||
if isinstance(field, DateTimeField):
|
||||
pass # DateTimeField subclasses DateField so must be checked first.
|
||||
# DateTimeField subclasses DateField so must be checked
|
||||
# first.
|
||||
pass
|
||||
elif isinstance(field, DateField):
|
||||
value = value.date()
|
||||
elif isinstance(field, TimeField) or (value.year == 1900 and value.month == value.day == 1):
|
||||
value = value.time()
|
||||
elif value.hour == value.minute == value.second == value.microsecond == 0:
|
||||
value = value.date()
|
||||
values.append(value)
|
||||
return values
|
||||
return value
|
||||
|
||||
def as_sql(self, with_limits=True, with_col_aliases=False):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user