Author: jchris Date: Thu Apr 22 15:17:39 2010 New Revision: 936893 URL: http://svn.apache.org/viewvc?rev=936893&view=rev Log: backport 936889 to 0.11.x
Modified: couchdb/branches/0.11.x/ (props changed) couchdb/branches/0.11.x/etc/default/couchdb (props changed) couchdb/branches/0.11.x/share/server/filter.js couchdb/branches/0.11.x/share/www/script/test/changes.js couchdb/branches/0.11.x/src/couchdb/couch_query_servers.erl Propchange: couchdb/branches/0.11.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Apr 22 15:17:39 2010 @@ -6,4 +6,4 @@ /couchdb/branches/list-iterator:782292-784593 /couchdb/branches/tail_header:775760-778477 /couchdb/tags/0.10.0:825400 -/couchdb/trunk:909247,910054,910696,910910-910911,911544,911559,911578,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707,923526,925264,931655,933039 +/couchdb/trunk:909247,910054,910696,910910-910911,911544,911559,911578,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707,923526,925264,931655,933039,936889 Propchange: couchdb/branches/0.11.x/etc/default/couchdb ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Apr 22 15:17:39 2010 @@ -6,5 +6,5 @@ /couchdb/branches/list-iterator/etc/default/couchdb:782292-784593 /couchdb/branches/tail_header/etc/default/couchdb:775760-778477 /couchdb/tags/0.10.0/etc/default/couchdb:825400 -/couchdb/trunk/etc/default/couchdb:909247,910054,910696,911544,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707,923526,925264,931655,933039 +/couchdb/trunk/etc/default/couchdb:909247,910054,910696,911544,911602,911717,911837,912474,912606,912608,912615,912636,915526,915529-915530,915827,916076,916153,916518,916521,917553,918855,919193,921707,923526,925264,931655,933039,936889 /incubator/couchdb/trunk/etc/default/couchdb:642419-694440 Modified: couchdb/branches/0.11.x/share/server/filter.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/server/filter.js?rev=936893&r1=936892&r2=936893&view=diff ============================================================================== --- couchdb/branches/0.11.x/share/server/filter.js (original) +++ couchdb/branches/0.11.x/share/server/filter.js Thu Apr 22 15:17:39 2010 @@ -15,9 +15,8 @@ var Filter = { var results = []; var docs = args[0]; var req = args[1]; - var userCtx = args[2]; for (var i=0; i < docs.length; i++) { - results.push((fun.apply(ddoc, [docs[i], req, userCtx]) && true) || false); + results.push((fun.apply(ddoc, [docs[i], req]) && true) || false); }; respond([true, results]); } Modified: couchdb/branches/0.11.x/share/www/script/test/changes.js URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/changes.js?rev=936893&r1=936892&r2=936893&view=diff ============================================================================== --- couchdb/branches/0.11.x/share/www/script/test/changes.js (original) +++ couchdb/branches/0.11.x/share/www/script/test/changes.js Thu Apr 22 15:17:39 2010 @@ -302,5 +302,44 @@ couchTests.changes = function(debug) { req = CouchDB.request("GET", "/test_suite_db/_changes?filter=changes_filter/conflicted"); resp = JSON.parse(req.responseText); T(resp.results.length == 1); + + // test with erlang filter function + run_on_modified_server([{ + section: "native_query_servers", + key: "erlang", + value: "{couch_native_process, start_link, []}" + }], function() { + var erl_ddoc = { + _id: "_design/erlang", + language: "erlang", + filters: { + foo: + 'fun({Doc}, Req) -> ' + + ' Value = proplists:get_value(<<"value">>, Doc),' + + ' (Value rem 2) =:= 0' + + 'end.' + } + }; + + db.deleteDb(); + db.createDb(); + T(db.save(erl_ddoc).ok); + + var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo"); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 0); + + T(db.save({_id: "doc1", value : 1}).ok); + T(db.save({_id: "doc2", value : 2}).ok); + T(db.save({_id: "doc3", value : 3}).ok); + T(db.save({_id: "doc4", value : 4}).ok); + + var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo"); + var resp = JSON.parse(req.responseText); + T(resp.results.length === 2); + T(resp.results[0].id === "doc2"); + T(resp.results[1].id === "doc4"); + }); + }; Modified: couchdb/branches/0.11.x/src/couchdb/couch_query_servers.erl URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_query_servers.erl?rev=936893&r1=936892&r2=936893&view=diff ============================================================================== --- couchdb/branches/0.11.x/src/couchdb/couch_query_servers.erl (original) +++ couchdb/branches/0.11.x/src/couchdb/couch_query_servers.erl Thu Apr 22 15:17:39 2010 @@ -190,8 +190,7 @@ filter_docs(Req, Db, DDoc, FName, Docs) couch_httpd_external:json_req_obj(HttpReq, Db) end, JsonDocs = [couch_doc:to_json_obj(Doc, [revs]) || Doc <- Docs], - JsonCtx = couch_util:json_user_ctx(Db), - [true, Passes] = ddoc_prompt(DDoc, [<<"filters">>, FName], [JsonDocs, JsonReq, JsonCtx]), + [true, Passes] = ddoc_prompt(DDoc, [<<"filters">>, FName], [JsonDocs, JsonReq]), {ok, Passes}. ddoc_proc_prompt({Proc, DDocId}, FunPath, Args) ->