Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

… case
  • Loading branch information...
commit c159d9cec0baab7bbd04d5d51a92a51e354a722a 1 parent 2249bd2
Anssi Kääriäinen authored October 27, 2012

Showing 1 changed file with 9 additions and 2 deletions. Show diff stats Hide diff stats

  1. 11  django/db/models/query.py
11  django/db/models/query.py
@@ -1418,8 +1418,15 @@ def get_cached_row(row, index_start, using,  klass_info, offset=0):
1418 1418
     fields = row[index_start : index_start + field_count]
1419 1419
     # If all the select_related columns are None, then the related
1420 1420
     # object must be non-existent - set the relation to None.
1421  
-    # Otherwise, construct the related object.
1422  
-    if fields == (None,) * field_count:
  1421
+    # Otherwise, construct the related object. Also, some backends treat ''
  1422
+    # and None equivalently for char fields, so we have to be prepared for
  1423
+    # '' values.
  1424
+    if connections[using].features.interprets_empty_strings_as_nulls:
  1425
+        vals = tuple([None if f == '' else f for f in fields])
  1426
+    else:
  1427
+        vals = fields
  1428
+
  1429
+    if vals == (None,) * field_count:
1423 1430
         obj = None
1424 1431
     else:
1425 1432
         if field_names:

0 notes on commit c159d9c

Please sign in to comment.
Something went wrong with that request. Please try again.