diff options
author | David Storch <david.storch@10gen.com> | 2014-10-27 22:01:27 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2014-10-27 22:01:27 -0400 |
commit | 5a9cd759519f5831efffa7015996526270f7e5ef (patch) | |
tree | 3bde80d329635a9b80370152412b7c1e325ed37d /jstests/core/explain_upsert.js | |
parent | 47c80ebc62f3e59e13a05b3301316e088cf278e7 (diff) | |
download | mongo-5a9cd759519f5831efffa7015996526270f7e5ef.tar.gz |
SERVER-15816 explained upserts against an empty collection shouldn't try to create a collection
Diffstat (limited to 'jstests/core/explain_upsert.js')
-rw-r--r-- | jstests/core/explain_upsert.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/jstests/core/explain_upsert.js b/jstests/core/explain_upsert.js new file mode 100644 index 00000000000..41282e9bf51 --- /dev/null +++ b/jstests/core/explain_upsert.js @@ -0,0 +1,36 @@ +// Test explain for {upsert: true} updates. + +var t = db.jstests_explain_upsert; +t.drop(); + +var explain; + +// Explained upsert against an empty collection should succeed and be a no-op. +explain = db.runCommand({ + explain: { + update: t.getName(), + updates: [ + {q: {a: 1}, u: {a: 1}, upsert: true} + ] + } +}); +assert.commandWorked(explain); + +// Collection should still not exist. +assert.eq(0, t.count()); +assert(!t.drop()); + +// Add a document to the collection. +t.insert({a: 3}); + +// An explained upsert against a non-empty collection should also succeed as a no-op. +explain = db.runCommand({ + explain: { + update: t.getName(), + updates: [ + {q: {a: 1}, u: {a: 1}, upsert: true} + ] + } +}); +assert.commandWorked(explain); +assert.eq(1, t.count()); |