Merge lp:~chipaca/u1db/fix_get-index-keys_utf8 into lp:u1db

Proposed by John Lenton
Status: Merged
Approved by: John A Meinel
Approved revision: 322
Merged at revision: 322
Proposed branch: lp:~chipaca/u1db/fix_get-index-keys_utf8
Merge into: lp:u1db
Diff against target: 32 lines (+10/-1)
2 files modified
u1db/commandline/client.py (+1/-1)
u1db/tests/commandline/test_client.py (+9/-0)
To merge this branch: bzr merge lp:~chipaca/u1db/fix_get-index-keys_utf8
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
John A Meinel (community) Approve
Review via email: mp+108940@code.launchpad.net

Commit message

Make u1db-client's get-index-keys work with non-ascii key values.

Description of the change

Make u1db-client's get-index-keys work with non-ascii key values.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/6/2012 3:31 PM, John Lenton wrote:
> John Lenton has proposed merging
> lp:~chipaca/u1db/fix_get-index-keys_utf8 into lp:u1db.
>
> Requested reviews: Ubuntu One hackers (ubuntuone-hackers) Related
> bugs: Bug #1009496 in U1DB: "u1db-client get-index-keys breaks on
> non-ascii documents" https://bugs.launchpad.net/u1db/+bug/1009496
>
> For more details, see:
> https://code.launchpad.net/~chipaca/u1db/fix_get-index-keys_utf8/+merge/108940
>
> Make u1db-client's get-index-keys work with non-ascii key values.

 merge: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/PYOwACgkQJdeBCYSNAAPyzgCeOSZgZ1o8pICN0tnDEbUCPVZ1
rlQAn0GBO2CdjnBl+VzrbF/MpFplqUI+
=ReV3
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good, tests pass

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1db/commandline/client.py'
2--- u1db/commandline/client.py 2012-05-31 18:51:20 +0000
3+++ u1db/commandline/client.py 2012-06-06 13:30:33 +0000
4@@ -402,7 +402,7 @@
5 try:
6 db = self._open(database, create=False)
7 for i in db.get_index_keys(index):
8- self.stdout.write("%s\n" % (i,))
9+ self.stdout.write("%s\n" % (i.encode('utf-8'),))
10 except errors.DatabaseDoesNotExist:
11 self.stderr.write("Database does not exist.\n")
12 except errors.IndexDoesNotExist:
13
14=== modified file 'u1db/tests/commandline/test_client.py'
15--- u1db/tests/commandline/test_client.py 2012-05-30 21:45:09 +0000
16+++ u1db/tests/commandline/test_client.py 2012-06-06 13:30:33 +0000
17@@ -623,6 +623,15 @@
18 self.assertEqual(cmd.stdout.getvalue(), '42\n')
19 self.assertEqual(cmd.stderr.getvalue(), '')
20
21+ def test_get_index_keys_nonascii(self):
22+ self.db.create_index("foo", "bar")
23+ self.db.create_doc('{"bar": "\u00a4"}')
24+ cmd = self.make_command(client.CmdGetIndexKeys)
25+ retval = cmd.run(self.db_path, "foo")
26+ self.assertEqual(retval, None)
27+ self.assertEqual(cmd.stdout.getvalue(), '\xc2\xa4\n')
28+ self.assertEqual(cmd.stderr.getvalue(), '')
29+
30 def test_get_index_keys_empty(self):
31 self.db.create_index("foo", "bar")
32 cmd = self.make_command(client.CmdGetIndexKeys)

Subscribers

People subscribed via source and target branches