Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7921: for sqlite3 2.4.1 or later, adapt str objects to unicode…

…, thus preveting weird failures with 8-bit bytestrings. Martin von Löwis and Karen Tracey tracked this one down -- thanks!

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8276 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 049d490875e8bcbc5977d4d63acff432a7ec824e 1 parent b5b1295
Jacob Kaplan-Moss authored August 09, 2008

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  django/db/backends/sqlite3/base.py
7  django/db/backends/sqlite3/base.py
@@ -37,6 +37,13 @@
37 37
 Database.register_converter("TIMESTAMP", util.typecast_timestamp)
38 38
 Database.register_converter("decimal", util.typecast_decimal)
39 39
 Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
  40
+if Database.version_info >= (2,4,1):
  41
+    # Starting in 2.4.1, the str type is not accepted anymore, therefore,
  42
+    # we convert all str objects to Unicode
  43
+    # As registering a adapter for a primitive type causes a small
  44
+    # slow-down, this adapter is only registered for sqlite3 versions
  45
+    # needing it.
  46
+    Database.register_adapter(str, lambda s:s.decode('utf-8'))
40 47
 
41 48
 class DatabaseFeatures(BaseDatabaseFeatures):
42 49
     supports_constraints = False

0 notes on commit 049d490

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