Browse files

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
  • Loading branch information...
1 parent 48bed8e commit f174f9dd8616577d195a562ccf2d02c8aecb19b1 Damien F. Katz committed Jul 18, 2008
Showing with 13 additions and 8 deletions.
  1. +12 −7 src/couchdb/couch_doc.erl
  2. +1 −1 src/couchdb/couch_rep.erl
View
19 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}) ->
View
2 src/couchdb/couch_rep.erl
@@ -241,7 +241,7 @@ open_db(DbName)->
enum_docs_since(DbUrl, StartSeq, InFun, InAcc) when is_list(DbUrl) ->
- Url = DbUrl ++ "_all_docs_by_seq?count=4&startkey=" ++ integer_to_list(StartSeq),
+ Url = DbUrl ++ "_all_docs_by_seq?count=100&startkey=" ++ integer_to_list(StartSeq),
{obj, Results} = do_http_request(Url, get),
DocInfoList=
lists:map(fun({obj, RowInfoList}) ->

0 comments on commit f174f9d

Please sign in to comment.