Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed Oracle failure caused by None converted to '' in select…

…_related case

Backpatch of c159d9c
  • Loading branch information...
commit fa1083fb0cfdce0fee4cbbf4d391ddb491223a0f 1 parent 18357bf
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 fa1083f

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