summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-01-15 12:28:56 -0500
committerScott Hernandez <scotthernandez@gmail.com>2016-01-19 14:30:17 -0500
commitefaa2ca55e7f91282a377f3e8ca0c0353a9f4fd7 (patch)
tree37284eda882fc23d53cf906cd535848a8ab7e1c4 /jstests/core
parent2953b302d66579d6db92cfd269eccb436801c03a (diff)
downloadmongo-efaa2ca55e7f91282a377f3e8ca0c0353a9f4fd7.tar.gz
SERVER-11983: do not create _id field on capped collection updates
(cherry picked from commit d50552399bdb5873444f7c49fe9986e009d5da22)
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/capped_update.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/jstests/core/capped_update.js b/jstests/core/capped_update.js
index 539bc2c8e85..ab93afed69f 100644
--- a/jstests/core/capped_update.js
+++ b/jstests/core/capped_update.js
@@ -1,11 +1,16 @@
/**
- * SERVER-20529: Ensure capped document sizes do not change
+ * Tests various update scenarios on capped collections:
+ * -- SERVER-20529: Ensure capped document sizes do not change
+ * -- SERVER-11983: Don't create _id field on capped updates
*/
(function() {
'use strict';
var t = db.cannot_change_capped_size;
t.drop();
- assert.commandWorked(db.createCollection(t.getName(), {capped: true, size: 1024}));
+ assert.commandWorked(db.createCollection(t.getName(), {capped: true,
+ size: 1024,
+ autoIndexId:false}));
+ assert.eq(0, t.getIndexes().length, "the capped collection has indexes");
for (var j = 1; j <= 10; j++) {
assert.writeOK(t.insert({_id: j, s: "Hello, World!"}));
@@ -15,4 +20,11 @@
assert.writeError(t.update({_id: 3}, {$set: {s: "Hello!"}}));
assert.writeError(t.update({_id: 10}, {}));
assert.writeError(t.update({_id: 10}, {s: "Hello, World!!!"}));
+
+ assert.commandWorked(t.getDB().runCommand({godinsert:t.getName(), obj:{a:2}}));
+ var doc = t.findOne({a:2});
+ assert.eq(undefined, doc["_id"], "now has _id after godinsert");
+ assert.writeOK(t.update({a:2}, {$inc:{a:1}}))
+ doc = t.findOne({a:3});
+ assert.eq(undefined, doc["_id"], "now has _id after update");
})();