couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [1/2] fauxton commit: updated refs/heads/master to a9ea5a0
Date Tue, 30 Sep 2014 16:55:23 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 2595b4bd2 -> a9ea5a0b4


Editor: don't replace custom id attribute with document-id

If we have a document with an id attribute "foo" and _id: "customid"
added from the user and we do a PUT request for an update,
CouchDB will return: {"ok":true, id: "customid", rev: "123"}

The Model will think it has the id "customid" instead of "foo"


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/a9ea5a0b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/a9ea5a0b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/a9ea5a0b

Branch: refs/heads/master
Commit: a9ea5a0b4f48d46c630ccc9d5a4696e075a9737e
Parents: 41bb798
Author: Robert Kowalski <rok@kowalski.gd>
Authored: Tue Sep 30 18:23:57 2014 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Tue Sep 30 18:54:36 2014 +0200

----------------------------------------------------------------------
 app/addons/documents/resources.js           |  1 +
 app/addons/documents/tests/resourcesSpec.js | 13 +++++++++++++
 2 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9ea5a0b/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/resources.js b/app/addons/documents/resources.js
index 7970acb..8077bfe 100644
--- a/app/addons/documents/resources.js
+++ b/app/addons/documents/resources.js
@@ -196,6 +196,7 @@ function(app, FauxtonAPI, PagingCollection) {
       }
 
       if (resp.ok) {
+        delete resp.id;
         delete resp.ok;
       }
 

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/a9ea5a0b/app/addons/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/resourcesSpec.js b/app/addons/documents/tests/resourcesSpec.js
index 7ac8939..1e3a612 100644
--- a/app/addons/documents/tests/resourcesSpec.js
+++ b/app/addons/documents/tests/resourcesSpec.js
@@ -48,6 +48,19 @@ define([
       });
       assert.equal(res.id, 'foo');
     });
+
+    it('removes the id, if we create a document and get back an "id" instead of "_id"', function
() {
+      // if we take the document {"_id": "mycustomid", "_rev": "18-9cdeb1b121137233e3466b06a1780c29",
id: "foo"}
+      // and do a PUT request for an update, CouchDB will return:
+      // {"ok":true,"id":"mycustomid","rev":"18-9cdeb1b121137233e3466b06a1780c29"}
+      // and our Model will think it has the id "mycustomid" instead of "foo"
+      var res = doc.parse({
+        id: "be31e531fe131bdf416b479ac1000484",
+        _rev: "4-3a1b9f4b988b413e9245cd250769da72",
+        ok: true
+      });
+      assert.notOk(res.id);
+    });
   });
 
   describe('AllDocs', function () {


Mime
View raw message