summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2016-07-06 17:38:10 -0400
committerJudah Schvimer <judah@mongodb.com>2016-07-06 17:38:10 -0400
commitb3611e663fb40505340589fd75fa5d504829c609 (patch)
treeb919f526a0e36f4ee93f6e16f911bd25c7dbb6c9 /jstests
parent8833b39af63a926fe7c8538e26666f3c2f20855b (diff)
downloadmongo-b3611e663fb40505340589fd75fa5d504829c609.tar.gz
SERVER-24883 cloner should not create _id index when original collection doesn't have one
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/copydatabase_no_id_index.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/jstests/core/copydatabase_no_id_index.js b/jstests/core/copydatabase_no_id_index.js
new file mode 100644
index 00000000000..2cd1225d78b
--- /dev/null
+++ b/jstests/core/copydatabase_no_id_index.js
@@ -0,0 +1,23 @@
+/**
+ * This test creates a collection with autoIndexId: false. It then copies the database and expects
+ * the new collection to not have an _id index either.
+ */
+
+(function() {
+ "use strict";
+ var db1 = db.getSiblingDB('copydatabase_no_id_index');
+ var db2 = db.getSiblingDB('copydatabase_no_id_index2');
+ db1.dropDatabase();
+ db2.dropDatabase();
+
+ assert.commandWorked(db1.runCommand({create: 'foo', autoIndexId: false}));
+ assert.writeOK(db1.foo.insert({a: 1}));
+ assert.eq(db1.foo.getIndexes().length, 0);
+
+ assert.commandWorked(db1.copyDatabase('copydatabase_no_id_index', 'copydatabase_no_id_index2'));
+
+ assert.eq(db1.foo.count(), 1);
+ assert.eq(db1.foo.getIndexes().length, 0);
+ assert.eq(db2.foo.count(), 1);
+ assert.eq(db2.foo.getIndexes().length, 0);
+})(); \ No newline at end of file