Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A39ED108AB for ; Mon, 22 Jul 2013 10:25:39 +0000 (UTC) Received: (qmail 12485 invoked by uid 500); 22 Jul 2013 10:25:31 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 11642 invoked by uid 500); 22 Jul 2013 10:25:25 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 10359 invoked by uid 99); 22 Jul 2013 10:25:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Jul 2013 10:25:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B96AC8B06CF; Mon, 22 Jul 2013 10:25:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jan@apache.org To: commits@couchdb.apache.org Date: Mon, 22 Jul 2013 10:25:39 -0000 Message-Id: <1674ea8deb4443bb85ec6a92d8380f1c@git.apache.org> In-Reply-To: <10f5b68774524227a2f788b7e382a844@git.apache.org> References: <10f5b68774524227a2f788b7e382a844@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [22/50] [abbrv] git commit: updated refs/heads/1684-feature-db-updates to ea07223 Restore rev handling for _bulk_docs with all_or_nothing Commit 5b1430c120904181313848444dbfcdb60e42568b added this hunk; - {aborted, lists:map( - fun({{Id,{Pos, [RevId|_]}}, Error}) -> - {{Id, {Pos, RevId}}, Error}; - ({{Id,{0, []}}, Error}) -> - {{Id, {0, <<>>}}, Error} - end, PreCommitFailures)}; + {aborted, + lists:foldl(fun({#doc{id=Id,revs={Pos, RevIds}}, Ref},Acc) -> + case lists:keyfind(Ref,1,PreCommitFailures) of + {Ref, Error} -> + [{{Id,{Pos,RevIds}}, Error} | Acc]; + false -> + Acc + end + end,[],Docs3)}; + This causes the full list of revisions to be passed to revid_to_str/1; revid_to_str(RevId) when size(RevId) =:= 16 -> ?l2b(couch_util:to_hex(RevId)); revid_to_str(RevId) -> RevId. This falls through to the second case, which in turn leads to invalid JSON output when we convert the presumed iolist. This patch restores the code that takes only the head of the revisions list when present, and an artificial "0-" when it is not (in the case that the validation fails for a new document rather than an update). BugzID: 1772 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/dfd39d57 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/dfd39d57 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/dfd39d57 Branch: refs/heads/1684-feature-db-updates Commit: dfd39d570f5f841ae5e003fc8b4a2073c267e89a Parents: 0bb6787 Author: Robert Newson Authored: Mon Jun 17 11:05:01 2013 +0100 Committer: Robert Newson Committed: Mon Jun 17 15:29:16 2013 +0100 ---------------------------------------------------------------------- src/couchdb/couch_db.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/dfd39d57/src/couchdb/couch_db.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 96f6719..11ea0fd 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -756,10 +756,15 @@ update_docs(Db, Docs, Options, interactive_edit) -> if (AllOrNothing) and (PreCommitFailures /= []) -> {aborted, - lists:foldl(fun({#doc{id=Id,revs={Pos, RevIds}}, Ref},Acc) -> + lists:foldl(fun({#doc{id=Id,revs=Revs}, Ref},Acc) -> case lists:keyfind(Ref,1,PreCommitFailures) of {Ref, Error} -> - [{{Id,{Pos,RevIds}}, Error} | Acc]; + case Revs of + {Pos, [RevId|_]} -> + [{{Id,{Pos, RevId}}, Error} | Acc]; + {0, []} -> + [{{Id,{0, <<>>}}, Error} | Acc] + end; false -> Acc end