couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r690055 - in /incubator/couchdb/branches/json_term_changes: share/www/script/couch_tests.js src/couchdb/couch_query_servers.erl src/couchdb/couch_view.erl
Date Fri, 29 Aug 2008 00:21:02 GMT
Author: damien
Date: Thu Aug 28 17:21:02 2008
New Revision: 690055

URL: http://svn.apache.org/viewvc?rev=690055&view=rev
Log:
Fix for error when javascript is not explicitly specified in the design doc.

Modified:
    incubator/couchdb/branches/json_term_changes/share/www/script/couch_tests.js
    incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl
    incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl

Modified: incubator/couchdb/branches/json_term_changes/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/share/www/script/couch_tests.js?rev=690055&r1=690054&r2=690055&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/branches/json_term_changes/share/www/script/couch_tests.js [utf-8] Thu
Aug 28 17:21:02 2008
@@ -828,7 +828,6 @@
     T(db.bulkSave(makeDocs(1, numDocs + 1)).ok);
 
     for (var loop = 0; loop < 2; loop++) {
-      if (db.view("test/all_docs") == null) throw "fuck";
       var rows = db.view("test/all_docs").rows;
       for (var i = 0; i < numDocs; i++) {
         T(rows[2*i].key == i+1);
@@ -837,8 +836,19 @@
       T(db.view("test/no_docs").total_rows == 0)
       T(db.view("test/single_doc").total_rows == 1)
       restartServer();
-    }
-
+    };
+    
+    // test when language not specified, Javascript is implied
+    var designDoc2 = {
+      _id:"_design/test2",
+      // language: "javascript", 
+      views: {
+        single_doc: {map: "function(doc) { if (doc._id == \"1\") { emit(1, null) }}"}
+      }
+    };
+    
+    T(db.save(designDoc2).ok);
+    T(db.view("test2/single_doc").total_rows == 1);
 
     var summate = function(N) {return (N+1)*N/2;};
     var result = db.view("test/summate");

Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl?rev=690055&r1=690054&r2=690055&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl Thu Aug
28 17:21:02 2008
@@ -187,18 +187,27 @@
             ?MODULE:stop()
         end),
         
-    QueryServerList = couch_config:lookup_match(
+    QueryServers = couch_config:lookup_match(
             {{"CouchDB Query Servers", '$1'}, '$2'}, []),
+    QueryServers2 = 
+        [{list_to_binary(Lang), Path} || {Lang, Path} <- QueryServers],
         
-    {ok, {QueryServerList, []}}.
+    {ok, {QueryServers2, []}}.
 
 terminate(_Reason, _Server) ->
     ok.
 
 
 handle_call({get_port, Lang}, {FromPid, _}, {QueryServerList, LangPorts}) ->
-    case lists:keysearch(Lang, 1, LangPorts) of
-    {value, {_, Port}=LangPort} ->
+    case proplists:get_value(Lang, LangPorts) of
+    undefined ->
+        case proplists:get_value(Lang, QueryServerList) of
+        undefined -> % not a supported language
+            {reply, {query_language_unknown, Lang}, {QueryServerList, LangPorts}};
+        ServerCmd ->
+            {reply, {empty, ServerCmd}, {QueryServerList, LangPorts}}
+        end;
+    Port ->
         Result =
         case catch port_connect(Port, FromPid) of
         true ->
@@ -208,14 +217,7 @@
             catch port_close(Port),
             Error
         end,
-        {reply, Result, {QueryServerList, LangPorts -- [LangPort]}};
-    false ->
-        case lists:keysearch(binary_to_list(Lang), 1, QueryServerList) of
-        {value, {_, ServerCmd}} ->
-            {reply, {empty, ServerCmd}, {QueryServerList, LangPorts}};
-        false -> % not a supported language
-            {reply, {query_language_unknown, Lang}, {QueryServerList, LangPorts}}
-        end
+        {reply, Result, {QueryServerList, LangPorts -- [{Lang,Port}]}}
     end;
 handle_call({return_port, {Lang, Port}}, _From, {QueryServerList, LangPorts}) ->
     case catch port_connect(Port, self()) of

Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl?rev=690055&r1=690054&r2=690055&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl Thu Aug 28 17:21:02
2008
@@ -175,7 +175,7 @@
                 
 
 design_doc_to_view_group(#doc{id=Id,body={Fields}}) ->
-    Language = proplists:get_value(<<"language">>, Fields, "javascript"),
+    Language = proplists:get_value(<<"language">>, Fields, <<"javascript">>),
     {RawViews} = proplists:get_value(<<"views">>, Fields, {[]}),
             
     % add the views to a dictionary object, with the map source as the key



Mime
View raw message