mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
boulder-oracle-sprint: Improved field type detection in QuerySet.resolve_columns. Now the only case where we have to guess at the field type is when select fields are added with QuerySet.extra.
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5024 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e558b9aac4
commit
b38a73e01a
@ -294,7 +294,8 @@ def get_query_set_class(DefaultQuerySet):
|
|||||||
cursor.execute(full_query, params)
|
cursor.execute(full_query, params)
|
||||||
|
|
||||||
fill_cache = self._select_related
|
fill_cache = self._select_related
|
||||||
index_end = len(self.model._meta.fields)
|
fields = self.model._meta.fields
|
||||||
|
index_end = len(fields)
|
||||||
|
|
||||||
# so here's the logic;
|
# so here's the logic;
|
||||||
# 1. retrieve each row in turn
|
# 1. retrieve each row in turn
|
||||||
@ -305,7 +306,7 @@ def get_query_set_class(DefaultQuerySet):
|
|||||||
if not rows:
|
if not rows:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row = self.resolve_columns(row)
|
row = self.resolve_columns(row, fields)
|
||||||
if fill_cache:
|
if fill_cache:
|
||||||
obj, index_end = get_cached_row(klass=self.model, row=row,
|
obj, index_end = get_cached_row(klass=self.model, row=row,
|
||||||
index_start=0, max_depth=self._max_related_depth)
|
index_start=0, max_depth=self._max_related_depth)
|
||||||
@ -480,12 +481,10 @@ def get_query_set_class(DefaultQuerySet):
|
|||||||
pass # DateTimeField subclasses DateField so must be checked first.
|
pass # DateTimeField subclasses DateField so must be checked first.
|
||||||
elif isinstance(field, DateField):
|
elif isinstance(field, DateField):
|
||||||
value = value.date()
|
value = value.date()
|
||||||
elif isinstance(field, TimeField):
|
elif isinstance(field, TimeField) or (value.year == 1900 and value.month == value.day == 1):
|
||||||
value = value.time()
|
value = value.time()
|
||||||
elif value.hour == value.minute == value.second == value.microsecond == 0:
|
elif value.hour == value.minute == value.second == value.microsecond == 0:
|
||||||
value = value.date()
|
value = value.date()
|
||||||
elif value.year == 1900 and value.month == value.day == 1:
|
|
||||||
value = value.time()
|
|
||||||
values.append(value)
|
values.append(value)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
@ -185,7 +185,8 @@ class _QuerySet(object):
|
|||||||
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params)
|
cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params)
|
||||||
|
|
||||||
fill_cache = self._select_related
|
fill_cache = self._select_related
|
||||||
index_end = len(self.model._meta.fields)
|
fields = self.model._meta.fields
|
||||||
|
index_end = len(fields)
|
||||||
has_resolve_columns = hasattr(self, 'resolve_columns')
|
has_resolve_columns = hasattr(self, 'resolve_columns')
|
||||||
while 1:
|
while 1:
|
||||||
rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)
|
rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)
|
||||||
@ -193,7 +194,7 @@ class _QuerySet(object):
|
|||||||
raise StopIteration
|
raise StopIteration
|
||||||
for row in rows:
|
for row in rows:
|
||||||
if has_resolve_columns:
|
if has_resolve_columns:
|
||||||
row = self.resolve_columns(row)
|
row = self.resolve_columns(row, fields)
|
||||||
if fill_cache:
|
if fill_cache:
|
||||||
obj, index_end = get_cached_row(klass=self.model, row=row,
|
obj, index_end = get_cached_row(klass=self.model, row=row,
|
||||||
index_start=0, max_depth=self._max_related_depth)
|
index_start=0, max_depth=self._max_related_depth)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user