Fixed Oracle failure caused by None converted to '' in select_related case

This commit is contained in:
Anssi Kääriäinen 2012-10-27 04:52:12 +03:00
parent 2249bd275c
commit c159d9cec0
1 changed files with 9 additions and 2 deletions

View File

@ -1418,8 +1418,15 @@ def get_cached_row(row, index_start, using, klass_info, offset=0):
fields = row[index_start : index_start + field_count] fields = row[index_start : index_start + field_count]
# If all the select_related columns are None, then the related # If all the select_related columns are None, then the related
# object must be non-existent - set the relation to None. # object must be non-existent - set the relation to None.
# Otherwise, construct the related object. # Otherwise, construct the related object. Also, some backends treat ''
if fields == (None,) * field_count: # and None equivalently for char fields, so we have to be prepared for
# '' values.
if connections[using].features.interprets_empty_strings_as_nulls:
vals = tuple([None if f == '' else f for f in fields])
else:
vals = fields
if vals == (None,) * field_count:
obj = None obj = None
else: else:
if field_names: if field_names: