Merge lp:~jameinel/u1db/http-uuid-993976 into lp:u1db

Proposed by John A Meinel
Status: Merged
Merged at revision: 276
Proposed branch: lp:~jameinel/u1db/http-uuid-993976
Merge into: lp:u1db
Diff against target: 24 lines (+2/-1)
2 files modified
u1db/remote/http_database.py (+1/-1)
u1db/tests/test_http_database.py (+1/-0)
To merge this branch: bzr merge lp:~jameinel/u1db/http-uuid-993976
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
Review via email: mp+105206@code.launchpad.net

Description of the change

This is a quick fix for bug #993976. Basically, create_doc for all other apis generates document ids starting with "D-". This is meant to make it a bit easier to distinguish random data that we might run into. (document revisions are uuids, so are document ids, etc.)

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1db/remote/http_database.py'
2--- u1db/remote/http_database.py 2012-05-07 19:14:38 +0000
3+++ u1db/remote/http_database.py 2012-05-09 13:24:18 +0000
4@@ -87,7 +87,7 @@
5
6 def create_doc(self, content, doc_id=None):
7 if doc_id is None:
8- doc_id = str(uuid.uuid4())
9+ doc_id = 'D-%s' % (uuid.uuid4().hex,)
10 res, headers = self._request_json('PUT', ['doc', doc_id], {},
11 content, 'application/json')
12 new_doc = Document(doc_id, res['rev'], content)
13
14=== modified file 'u1db/tests/test_http_database.py'
15--- u1db/tests/test_http_database.py 2012-03-01 19:22:52 +0000
16+++ u1db/tests/test_http_database.py 2012-05-09 13:24:18 +0000
17@@ -137,6 +137,7 @@
18 def test_create_doc_without_id(self):
19 self.response_val = {'rev': 'doc-rev-2'}, {}
20 new_doc = self.db.create_doc('{"v": 3}')
21+ self.assertEqual('D-', new_doc.doc_id[:2])
22 self.assertEqual('doc-rev-2', new_doc.rev)
23 self.assertEqual('{"v": 3}', new_doc.content)
24 self.assertEqual(('PUT', ['doc', new_doc.doc_id], {},

Subscribers

People subscribed via source and target branches