summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-10-27 04:52:12 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-10-27 19:25:14 +0300
commitfa1083fb0cfdce0fee4cbbf4d391ddb491223a0f (patch)
tree955d4e1c3ea30aa3f55bb5bc66dc2e7aacab3d96
parent18357bf3acae0c70e4fd3b692efb4db7638cb574 (diff)
[1.5.x] Fixed Oracle failure caused by None converted to '' in select_related case
Backpatch of c159d9cec0baab7bbd04d5d51a92a51e354a722a
-rw-r--r--django/db/models/query.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index dc1ddf1606..da4c69f362 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1418,8 +1418,15 @@ def get_cached_row(row, index_start, using, klass_info, offset=0):
fields = row[index_start : index_start + field_count]
# If all the select_related columns are None, then the related
# object must be non-existent - set the relation to None.
- # Otherwise, construct the related object.
- if fields == (None,) * field_count:
+ # Otherwise, construct the related object. Also, some backends treat ''
+ # 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
else:
if field_names: