summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS1
-rw-r--r--share/www/script/test/attachments.js20
-rw-r--r--src/couchdb/couch_doc.erl4
3 files changed, 23 insertions, 2 deletions
diff --git a/THANKS b/THANKS
index 7ed26d0e..e016c467 100644
--- a/THANKS
+++ b/THANKS
@@ -63,5 +63,6 @@ suggesting improvements or submitting changes. Some of these people are:
* Zachary Zolton <zachary.zolton@gmail.com>
* Brian Jenkins <bonkydog@bonkydog.com>
* Paul Bonser <pib@paulbonser.com>
+ * Caleb Land <caleb.land@gmail.com>
For a list of authors see the `AUTHORS` file.
diff --git a/share/www/script/test/attachments.js b/share/www/script/test/attachments.js
index 36f5a5ad..322a4f50 100644
--- a/share/www/script/test/attachments.js
+++ b/share/www/script/test/attachments.js
@@ -244,4 +244,24 @@ couchTests.attachments= function(debug) {
body: "THIS IS AN ATTACHMENT. BOOYA!"
});
TEquals(400, xhr.status, "should return error code 400 Bad Request");
+
+ // test COUCHDB-809 - stubs should only require the 'stub' field
+ var bin_doc6 = {
+ _id: "bin_doc6",
+ _attachments:{
+ "foo.txt": {
+ content_type:"text/plain",
+ data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+ }
+ }
+ }
+ var save_response = db.save(bin_doc6);
+ bin_doc6._rev = save_response["rev"];
+ // stub out the attachment
+ bin_doc6._attachments["foo.txt"] = { stub: true };
+
+ var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc6", {
+ body: JSON.stringify(bin_doc6)
+ });
+ TEquals(201, xhr.status, "should send 201 Created when attachment stub contains only the 'stub' field");
};
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index 6c8f522d..0a71f2e3 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -357,9 +357,9 @@ has_stubs([_Att|Rest]) ->
merge_stubs(#doc{id=Id,atts=MemBins}=StubsDoc, #doc{atts=DiskBins}) ->
BinDict = dict:from_list([{Name, Att} || #att{name=Name}=Att <- DiskBins]),
MergedBins = lists:map(
- fun(#att{name=Name, data=stub, revpos=RevPos}) ->
+ fun(#att{name=Name, data=stub}) ->
case dict:find(Name, BinDict) of
- {ok, #att{revpos=RevPos}=DiskAtt} ->
+ {ok, #att{}=DiskAtt} ->
DiskAtt;
_ ->
throw({missing_stub,