You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2008/08/28 23:28:06 UTC

svn commit: r689996 - in /incubator/couchdb/branches/json_term_changes: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl

Author: damien
Date: Thu Aug 28 14:28:06 2008
New Revision: 689996

URL: http://svn.apache.org/viewvc?rev=689996&view=rev
Log:
Fix for missing document ID when creating new documents view bulk post, and fix the welcome message.

Modified:
    incubator/couchdb/branches/json_term_changes/share/www/script/couch_tests.js
    incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.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=689996&r1=689995&r2=689996&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 14:28:06 2008
@@ -14,6 +14,9 @@
 
   // Do some basic tests.
   basics: function(debug) {
+    var result = JSON.parse(CouchDB.request("GET", "/").responseText);
+    T(result.couchdb == "Welcome"); 
+    
     var db = new CouchDB("test_suite_db");
     db.deleteDb();
 
@@ -311,6 +314,15 @@
     for (i = 0; i < 5; i++) {
       T(db.open(docs[i]._id) == null);
     }
+    
+    // verify creating a document with no id returns a new id
+    var req = CouchDB.request("POST", "/test_suite_db/_bulk_docs", {
+      body: JSON.stringify({"docs": [{"foo":"bar"}]})
+    });
+    result = JSON.parse(req.responseText);
+    
+    T(result.new_revs[0].id != "");
+    T(result.new_revs[0].rev != "");
   },
 
   // test saving a semi-large quanitity of documents and do some view queries.

Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl?rev=689996&r1=689995&r2=689996&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl Thu Aug 28 14:28:06 2008
@@ -149,8 +149,8 @@
 
 handle_welcome_request(Req, 'GET') ->
     send_json(Req, {[
-        {"couchdb", "Welcome"},
-        {"version", couch_server:get_version()}
+        {couchdb, <<"Welcome">>},
+        {version, list_to_binary(couch_server:get_version())}
     ]});
 
 handle_welcome_request(_Req, _Method) ->
@@ -266,7 +266,7 @@
             fun({ObjProps} = JsonObj) ->
                 Doc = couch_doc:from_json_obj(JsonObj),
                 Id = case Doc#doc.id of
-                    "" -> couch_util:new_uuid();
+                    <<>> -> couch_util:new_uuid();
                     Id0 -> Id0
                 end,
                 Revs = case proplists:get_value(<<"_rev">>, ObjProps) of



Re: svn commit: r689996 - in /incubator/couchdb/branches/json_term_changes: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl

Posted by Damien Katz <da...@apache.org>.
On Aug 28, 2008, at 5:28 PM, damien@apache.org wrote:

> Author: damien
> Date: Thu Aug 28 14:28:06 2008
> New Revision: 689996
>
> URL: http://svn.apache.org/viewvc?rev=689996&view=rev
> Log:
> Fix for missing document ID when creating new documents view bulk  
> post, and fix the welcome message.


Doh, that should say "via bulk post".

-Damien

Re: svn commit: r689996 - in /incubator/couchdb/branches/json_term_changes: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl

Posted by Damien Katz <da...@apache.org>.
On Aug 28, 2008, at 5:28 PM, damien@apache.org wrote:

> Author: damien
> Date: Thu Aug 28 14:28:06 2008
> New Revision: 689996
>
> URL: http://svn.apache.org/viewvc?rev=689996&view=rev
> Log:
> Fix for missing document ID when creating new documents view bulk  
> post, and fix the welcome message.


Doh, that should say "via bulk post".

-Damien

Re: svn commit: r689996 - in /incubator/couchdb/branches/json_term_changes: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl

Posted by Damien Katz <da...@apache.org>.
Found and fixed. Thanks.

-Damien


On Aug 28, 2008, at 7:03 PM, Michael Hendricks wrote:

> On Thu, Aug 28, 2008 at 09:28:06PM -0000, damien@apache.org wrote:
>> Author: damien
>> Date: Thu Aug 28 14:28:06 2008
>> New Revision: 689996
>>
>> URL: http://svn.apache.org/viewvc?rev=689996&view=rev
>> Log:
>> Fix for missing document ID when creating new documents view bulk
>> post, and fix the welcome message.
>
> Thanks Damien.  I found another bug on the json_term_changes branch.
> When I examine a view and CouchDB tries to spawn a new javascript
> instance, I got a 500 error and the following output:
>
>    {"error":"error",
>    "reason":"{{badarg,[
>        {erlang,binary_to_list,[\"javascript\"]},
>        {couch_query_servers,handle_call,3},
>        {gen_server,handle_msg,5},
>        {proc_lib,init_p,5}]},
>        {gen_server,call, [couch_query_servers,{get_port,\"javascript 
> \"}]}}"}
>
> The patch below fixes it.  I'm not sure why the test suite didn't  
> catch
> it though.  The only other problem I've found on this branch  
> (creating a
> database that already exists) is a regression on trunk too.  I sent a
> patch for that on 23 August.
>
> --- couch_query_servers.erl     (revision 690030)
> +++ couch_query_servers.erl     (working copy)
> @@ -210,7 +210,7 @@
>         end,
>         {reply, Result, {QueryServerList, LangPorts -- [LangPort]}};
>     false ->
> -        case lists:keysearch(binary_to_list(Lang), 1,  
> QueryServerList) of
> +        case lists:keysearch(Lang, 1, QueryServerList) of
>         {value, {_, ServerCmd}} ->
>             {reply, {empty, ServerCmd}, {QueryServerList, LangPorts}};
>         false -> % not a supported language
>
> -- 
> Michael


Re: svn commit: r689996 - in /incubator/couchdb/branches/json_term_changes: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl

Posted by Michael Hendricks <mi...@ndrix.org>.
On Thu, Aug 28, 2008 at 09:28:06PM -0000, damien@apache.org wrote:
> Author: damien
> Date: Thu Aug 28 14:28:06 2008
> New Revision: 689996
> 
> URL: http://svn.apache.org/viewvc?rev=689996&view=rev
> Log:
> Fix for missing document ID when creating new documents view bulk
> post, and fix the welcome message.

Thanks Damien.  I found another bug on the json_term_changes branch.
When I examine a view and CouchDB tries to spawn a new javascript
instance, I got a 500 error and the following output:

    {"error":"error",
    "reason":"{{badarg,[
        {erlang,binary_to_list,[\"javascript\"]},
        {couch_query_servers,handle_call,3},
        {gen_server,handle_msg,5},
        {proc_lib,init_p,5}]},
        {gen_server,call, [couch_query_servers,{get_port,\"javascript\"}]}}"}

The patch below fixes it.  I'm not sure why the test suite didn't catch
it though.  The only other problem I've found on this branch (creating a
database that already exists) is a regression on trunk too.  I sent a
patch for that on 23 August.

--- couch_query_servers.erl     (revision 690030)
+++ couch_query_servers.erl     (working copy)
@@ -210,7 +210,7 @@
         end,
         {reply, Result, {QueryServerList, LangPorts -- [LangPort]}};
     false ->
-        case lists:keysearch(binary_to_list(Lang), 1, QueryServerList) of
+        case lists:keysearch(Lang, 1, QueryServerList) of
         {value, {_, ServerCmd}} ->
             {reply, {empty, ServerCmd}, {QueryServerList, LangPorts}};
         false -> % not a supported language

-- 
Michael