summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_doc.erl
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-07-18 12:57:07 +0000
committerDamien F. Katz <damien@apache.org>2008-07-18 12:57:07 +0000
commitf174f9dd8616577d195a562ccf2d02c8aecb19b1 (patch)
treee0ef7dd306890efcdf8213d2f3288caf4a056e8f /src/couchdb/couch_doc.erl
parent48bed8e9d4d898708df8ebcb76c3db3ce64e1a2d (diff)
Fix for problem when saving bulk documents with invalid ids
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@677892 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_doc.erl')
-rw-r--r--src/couchdb/couch_doc.erl19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index 9b7d6db9..61685cfa 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -110,13 +110,18 @@ from_json_obj({obj, Props}) ->
Revs0 ->
Revs0
end,
- #doc{
- id = proplists:get_value("_id", Props, ""),
- revs = Revs,
- deleted = proplists:get_value("_deleted", Props, false),
- body = {obj, [{Key, Value} || {[FirstChar|_]=Key, Value} <- Props, FirstChar /= $_]},
- attachments = Bins
- }.
+ case proplists:get_value("_id", Props, "") of
+ Id when is_list(Id) ->
+ #doc{
+ id = Id,
+ revs = Revs,
+ deleted = proplists:get_value("_deleted", Props, false),
+ body = {obj, [{Key, Value} || {[FirstChar|_]=Key, Value} <- Props, FirstChar /= $_]},
+ attachments = Bins
+ };
+ _ ->
+ throw({invalid_document_id, "Document id is not a string"})
+ end.
to_doc_info(#full_doc_info{id=Id,update_seq=Seq,rev_tree=Tree}) ->