From 049d490875e8bcbc5977d4d63acff432a7ec824e Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Sat, 9 Aug 2008 23:59:01 +0000 Subject: [PATCH] =?UTF-8?q?Fixed=20#7921:=20for=20sqlite3=202.4.1=20or=20l?= =?UTF-8?q?ater,=20adapt=20str=20objects=20to=20unicode,=20thus=20prevetin?= =?UTF-8?q?g=20weird=20failures=20with=208-bit=20bytestrings.=20Martin=20v?= =?UTF-8?q?on=20L=C3=B6wis=20and=20Karen=20Tracey=20tracked=20this=20one?= =?UTF-8?q?=20down=20--=20thanks!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@8276 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/backends/sqlite3/base.py | 7 +++++++ 1 file changed, 7 insertions(+) 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