couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Hendricks <mich...@ndrix.org>
Subject [PATCH] Status code when creating a database twice
Date Sat, 23 Aug 2008 06:08:16 GMT
Up until recently, trying to create a database that already existed
produced a 409 HTTP status code (instead of 500).  This patch restores
the 409 behavior and the error reason: 'Database "foo" already exists'.

Signed-off-by: Michael Hendricks <michael@ndrix.org>
---
 share/www/script/couch_tests.js |    4 ++++
 src/couchdb/couch_server.erl    |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index fd6eaed..5a08b25 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -21,6 +21,10 @@ var tests = {
     db.deleteDb();
     
     db.createDb();
+
+    // PUT on existing DB should return 409 instead of 500
+    xhr = CouchDB.request("PUT", "/test_suite_db/");
+    T(xhr.status == 409);
     if (debug) debugger;
 
     // Get the database info, check the doc_count
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl
index 3fa2386..f45d32f 100644
--- a/src/couchdb/couch_server.erl
+++ b/src/couchdb/couch_server.erl
@@ -231,7 +231,7 @@ handle_call({create, DbName, Options}, {FromPid,_}, Server) ->
                 {reply, Error, Server}
             end;
         [_AlreadyRunningDb] ->
-            {reply, {error, file_exists}, Server}
+            {reply, {error, database_already_exists}, Server}
         end;
     Error ->
         {reply, Error, Server}
-- 
1.5.6


Mime
View raw message