Skip to content

Commit e589c60

Browse files
author
Richard Jones
committed
unicode / sqlite 3 problem [SF#1589292]
1 parent cacae7c commit e589c60

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ are given with the most recent entry first.
55
Fixed:
66
- setup.py had broken reference to roundup.cgi (sf bug 1593573)
77
- full-text search wasn't coping with multiple multilinks to the same class
8+
- unicode / sqlite 3 problem (sf bug 1589292)
89

910

1011
2006-09-11 1.3.0

roundup/backends/back_sqlite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_sqlite.py,v 1.48 2006-10-10 03:55:31 richard Exp $
1+
# $Id: back_sqlite.py,v 1.49 2006-11-11 03:21:12 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -61,7 +61,7 @@ class Database(rdbms_common.Database):
6161
hyperdb.Multilink : lambda x: x, # used in journal marshalling
6262
}
6363
sql_to_hyperdb_value = {
64-
hyperdb.String : str,
64+
hyperdb.String : lambda x: isinstance(x, unicode) and x.encode('utf8') or str(x),
6565
hyperdb.Date : lambda x: date.Date(str(x)),
6666
hyperdb.Link : str, # XXX numeric ids
6767
hyperdb.Interval : date.Interval,

test/db_test_base.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.81 2006-11-11 03:01:54 richard Exp $
18+
# $Id: db_test_base.py,v 1.82 2006-11-11 03:21:12 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint, sets
2121

@@ -202,6 +202,18 @@ def testFileClassContentChange(self):
202202
if commit: self.db.commit()
203203
self.assertEqual(self.db.file.get(nid, 'content'), 'eggs')
204204

205+
def testStringUnicode(self):
206+
# test set & retrieve
207+
ustr = u'\xe4\xf6\xfc\u20ac'.encode('utf8')
208+
nid = self.db.issue.create(title=ustr, status='1')
209+
self.assertEqual(self.db.issue.get(nid, 'title'), ustr)
210+
211+
# change and make sure we retrieve the correct value
212+
ustr2 = u'change \u20ac change'.encode('utf8')
213+
self.db.issue.set(nid, title=ustr2)
214+
self.db.commit()
215+
self.assertEqual(self.db.issue.get(nid, 'title'), ustr2)
216+
205217
# Link
206218
def testLinkChange(self):
207219
self.assertRaises(IndexError, self.db.issue.create, title="spam",

0 commit comments

Comments
 (0)