From 5a87b852a72cc36d4d7b64271ed542ce2a1befe0 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sat, 23 Jan 2010 15:29:33 +0000 Subject: show conflicts in changes filters. Patch by Lena Herrmann. Closes COUCHDB-630 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@902422 13f79535-47bb-0310-9956-ffa450edef68 --- THANKS | 1 + share/www/script/test/changes.js | 15 ++++++++++++--- src/couchdb/couch_httpd_db.erl | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/THANKS b/THANKS index 83f47153..8d307650 100644 --- a/THANKS +++ b/THANKS @@ -42,5 +42,6 @@ suggesting improvements or submitting changes. Some of these people are: * Matthew Hooker * Filipe Manana * Ilia Cheishvili + * Lena Herrmann For a list of authors see the `AUTHORS` file. diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js index cb6640eb..a7703d77 100644 --- a/share/www/script/test/changes.js +++ b/share/www/script/test/changes.js @@ -175,7 +175,8 @@ couchTests.changes = function(debug) { }), "userCtx" : stringFun(function(doc, req) { return doc.user && (doc.user == req.userCtx.name); - }) + }), + "conflicted" : "function(doc, req) { return (doc._conflicts);}", } } @@ -286,11 +287,19 @@ couchTests.changes = function(debug) { resp = JSON.parse(req.responseText); T(resp.results.length == 1, "userCtx"); T(resp.results[0].id == docResp.id); - }); + } + ); req = CouchDB.request("GET", "/test_suite_db/_changes?limit=1"); resp = JSON.parse(req.responseText); - TEquals(1, resp.results.length); + TEquals(1, resp.results.length) + //filter includes _conflicts + var id = db.save({'food' : 'pizza'}).id; + db.bulkSave([{_id: id, 'food' : 'pasta'}], {all_or_nothing:true}); + req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/conflicted"); + resp = JSON.parse(req.responseText); + T(resp.results.length == 1); }; + diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 28efc90e..dd13cb59 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -237,7 +237,7 @@ make_filter_fun(Req, Db) -> couch_util:get_nested_json_value({Props}, [<<"filters">>, FName]), fun(DocInfos) -> Docs = [Doc || {ok, Doc} <- [ - {ok, Doc} = couch_db:open_doc(Db, DInfo, [deleted]) + {ok, Doc} = couch_db:open_doc(Db, DInfo, [deleted, conflicts]) || DInfo <- DocInfos]], {ok, Passes} = couch_query_servers:filter_docs(Req, Db, DDoc, FName, Docs), [{[{rev, couch_doc:rev_to_str(Rev)}]} -- cgit v1.2.3