Mercurial > p > roundup > code
changeset 3752:c92687dce135
unicode / sqlite 3 problem [SF#1589292]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sat, 11 Nov 2006 03:21:12 +0000 |
| parents | 44603dd791b7 |
| children | a6eff0dd2c9c |
| files | CHANGES.txt roundup/backends/back_sqlite.py test/db_test_base.py |
| diffstat | 3 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Sat Nov 11 03:01:54 2006 +0000 +++ b/CHANGES.txt Sat Nov 11 03:21:12 2006 +0000 @@ -5,6 +5,7 @@ Fixed: - setup.py had broken reference to roundup.cgi (sf bug 1593573) - full-text search wasn't coping with multiple multilinks to the same class +- unicode / sqlite 3 problem (sf bug 1589292) 2006-09-11 1.3.0
--- a/roundup/backends/back_sqlite.py Sat Nov 11 03:01:54 2006 +0000 +++ b/roundup/backends/back_sqlite.py Sat Nov 11 03:21:12 2006 +0000 @@ -1,4 +1,4 @@ -# $Id: back_sqlite.py,v 1.48 2006-10-10 03:55:31 richard Exp $ +# $Id: back_sqlite.py,v 1.49 2006-11-11 03:21:12 richard Exp $ '''Implements a backend for SQLite. See https://pysqlite.sourceforge.net/ for pysqlite info @@ -61,7 +61,7 @@ hyperdb.Multilink : lambda x: x, # used in journal marshalling } sql_to_hyperdb_value = { - hyperdb.String : str, + hyperdb.String : lambda x: isinstance(x, unicode) and x.encode('utf8') or str(x), hyperdb.Date : lambda x: date.Date(str(x)), hyperdb.Link : str, # XXX numeric ids hyperdb.Interval : date.Interval,
--- a/test/db_test_base.py Sat Nov 11 03:01:54 2006 +0000 +++ b/test/db_test_base.py Sat Nov 11 03:21:12 2006 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: db_test_base.py,v 1.81 2006-11-11 03:01:54 richard Exp $ +# $Id: db_test_base.py,v 1.82 2006-11-11 03:21:12 richard Exp $ import unittest, os, shutil, errno, imp, sys, time, pprint, sets @@ -202,6 +202,18 @@ if commit: self.db.commit() self.assertEqual(self.db.file.get(nid, 'content'), 'eggs') + def testStringUnicode(self): + # test set & retrieve + ustr = u'\xe4\xf6\xfc\u20ac'.encode('utf8') + nid = self.db.issue.create(title=ustr, status='1') + self.assertEqual(self.db.issue.get(nid, 'title'), ustr) + + # change and make sure we retrieve the correct value + ustr2 = u'change \u20ac change'.encode('utf8') + self.db.issue.set(nid, title=ustr2) + self.db.commit() + self.assertEqual(self.db.issue.get(nid, 'title'), ustr2) + # Link def testLinkChange(self): self.assertRaises(IndexError, self.db.issue.create, title="spam",
