Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent b5b1295 commit 049d490875e8bcbc5977d4d63acff432a7ec824e @jacobian jacobian committed
Showing with 7 additions and 0 deletions.
  1. +7 −0 django/db/backends/sqlite3/
7 django/db/backends/sqlite3/
@@ -37,6 +37,13 @@
Database.register_converter("TIMESTAMP", util.typecast_timestamp)
Database.register_converter("decimal", util.typecast_decimal)
Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
+if Database.version_info >= (2,4,1):
+ # Starting in 2.4.1, the str type is not accepted anymore, therefore,
+ # we convert all str objects to Unicode
+ # As registering a adapter for a primitive type causes a small
+ # slow-down, this adapter is only registered for sqlite3 versions
+ # needing it.
+ Database.register_adapter(str, lambda s:s.decode('utf-8'))
class DatabaseFeatures(BaseDatabaseFeatures):
supports_constraints = False

0 comments on commit 049d490

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