You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/09/30 18:55:23 UTC

[1/2] fauxton commit: updated refs/heads/master to a9ea5a0

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 <ro...@kowalski.gd>
Authored: Tue Sep 30 18:23:57 2014 +0200
Committer: Garren Smith <ga...@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 () {


[2/2] fauxton commit: updated refs/heads/master to a9ea5a0

Posted by ga...@apache.org.
Editor: do not remove id field for docs

COUCHDB-2341


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

Branch: refs/heads/master
Commit: 41bb798d515f3a3f8f85927bfa61324e7e683420
Parents: 2595b4b
Author: Robert Kowalski <ro...@kowalski.gd>
Authored: Tue Sep 30 17:28:47 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Sep 30 18:54:36 2014 +0200

----------------------------------------------------------------------
 app/addons/documents/resources.js           |  4 +---
 app/addons/documents/tests/resourcesSpec.js | 16 ++++++++++++++++
 app/addons/documents/views-doceditor.js     |  8 +++-----
 3 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/41bb798d/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/resources.js b/app/addons/documents/resources.js
index 250e302..7970acb 100644
--- a/app/addons/documents/resources.js
+++ b/app/addons/documents/resources.js
@@ -193,8 +193,6 @@ function(app, FauxtonAPI, PagingCollection) {
         if (typeof(this.id) === "undefined") {
           resp._id = resp.id;
         }
-
-        delete resp.id;
       }
 
       if (resp.ok) {
@@ -514,7 +512,7 @@ function(app, FauxtonAPI, PagingCollection) {
 
     urlRef: function(context, params) {
       var query = "";
-      
+
       if (params) {
         if (!_.isEmpty(params)) {
           query = "?" + $.param(params);

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/41bb798d/app/addons/documents/tests/resourcesSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/tests/resourcesSpec.js b/app/addons/documents/tests/resourcesSpec.js
index 1159360..7ac8939 100644
--- a/app/addons/documents/tests/resourcesSpec.js
+++ b/app/addons/documents/tests/resourcesSpec.js
@@ -34,6 +34,22 @@ define([
 
   });
 
+  describe('Document', function () {
+    var doc;
+    beforeEach(function () {
+      doc = new Models.Doc({}, {});
+    });
+
+    it('does not remove an id attribute', function () {
+      var res = doc.parse({
+        _id: "be31e531fe131bdf416b479ac1000484",
+        _rev: "4-3a1b9f4b988b413e9245cd250769da72",
+        id: "foo"
+      });
+      assert.equal(res.id, 'foo');
+    });
+  });
+
   describe('AllDocs', function () {
     var collection;
     beforeEach(function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/41bb798d/app/addons/documents/views-doceditor.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views-doceditor.js b/app/addons/documents/views-doceditor.js
index d1cc85c..3633edc 100644
--- a/app/addons/documents/views-doceditor.js
+++ b/app/addons/documents/views-doceditor.js
@@ -377,13 +377,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, resizeColumns, prett
 
     saveDoc: function(event) {
       var json,
-      that = this,
-      editor = this.editor,
-      validDoc = this.getDocFromEditor();
+          that = this,
+          editor = this.editor,
+          validDoc = this.getDocFromEditor();
 
       if (validDoc) {
-        this.getDocFromEditor();
-
         FauxtonAPI.addNotification({msg: "Saving document."});
 
         this.model.save().then(function () {