Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10238: coerce TextField values to unicode in the oracle backend.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10049 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0ae95f80b4030b6ad716838f45da45b9c34e612a 1 parent f725658
Ian Kelly authored March 13, 2009
4  django/db/backends/oracle/query.py
@@ -6,6 +6,7 @@
6 6
 import datetime
7 7
 
8 8
 from django.db.backends import util
  9
+from django.utils.encoding import force_unicode
9 10
 
10 11
 # Cache. Maps default query class to new Oracle query class.
11 12
 _classes = {}
@@ -55,6 +56,9 @@ def resolve_columns(self, row, fields=()):
55 56
         def convert_values(self, value, field):
56 57
             if isinstance(value, Database.LOB):
57 58
                 value = value.read()
  59
+                if field and field.get_internal_type() == 'TextField':
  60
+                    value = force_unicode(value)
  61
+                    
58 62
             # Oracle stores empty strings as null. We need to undo this in
59 63
             # order to adhere to the Django convention of using the empty
60 64
             # string instead of null, but only if the field accepts the
7  tests/regressiontests/datatypes/models.py
@@ -13,6 +13,7 @@ class Donut(models.Model):
13 13
     baked_date = models.DateField(null=True)
14 14
     baked_time = models.TimeField(null=True)
15 15
     consumed_at = models.DateTimeField(null=True)
  16
+    review = models.TextField()
16 17
 
17 18
     class Meta:
18 19
         ordering = ('consumed_at',)
@@ -82,6 +83,12 @@ def __str__(self):
82 83
 >>> Donut.objects.filter(consumed_at__year=2008)
83 84
 []
84 85
 
  86
+# Regression test for #10238: TextField values returned from the database
  87
+# should be unicode.
  88
+>>> d2 = Donut.objects.create(name=u'Jelly Donut', review=u'Outstanding')
  89
+>>> Donut.objects.get(id=d2.id).review
  90
+u'Outstanding'
  91
+
85 92
 """}
86 93
 
87 94
 # Regression test for #8354: the MySQL backend should raise an error if given

0 notes on commit 0ae95f8

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