diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-08-09 23:59:01 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-08-09 23:59:01 +0000 |
| commit | 049d490875e8bcbc5977d4d63acff432a7ec824e (patch) | |
| tree | 5ca14a2b4d1f4bb12faebd143350be41f56f595e | |
| parent | b5b129567e476f89faf3897da3481a29ca99d041 (diff) | |
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
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 71be86f00b..e7d9f25a97 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -37,6 +37,13 @@ Database.register_converter("timestamp", util.typecast_timestamp) 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 |
