summaryrefslogtreecommitdiff
path: root/jstests/core/collation.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/collation.js')
-rw-r--r--jstests/core/collation.js82
1 files changed, 47 insertions, 35 deletions
diff --git a/jstests/core/collation.js b/jstests/core/collation.js
index 5a24b133de0..8458db5e4b3 100644
--- a/jstests/core/collation.js
+++ b/jstests/core/collation.js
@@ -692,18 +692,21 @@
assert.neq(null, planStage);
// Find with oplog replay should return correct results when no collation specified and
- // collection has a default collation.
- coll.drop();
- assert.commandWorked(db.createCollection(
- coll.getName(),
- {collation: {locale: "en_US", strength: 2}, capped: true, size: 16 * 1024}));
- assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 0)}));
- assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 1)}));
- assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 2)}));
- assert.eq(2,
- coll.find({str: "foo", ts: {$gte: Timestamp(1000, 1)}})
- .addOption(DBQuery.Option.oplogReplay)
- .itcount());
+ // collection has a default collation. Skip this test for the mobile SE because it doesn't
+ // support capped collections which are needed for oplog replay.
+ if (jsTest.options().storageEngine !== "mobile") {
+ coll.drop();
+ assert.commandWorked(db.createCollection(
+ coll.getName(),
+ {collation: {locale: "en_US", strength: 2}, capped: true, size: 16 * 1024}));
+ assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 0)}));
+ assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 1)}));
+ assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 2)}));
+ assert.eq(2,
+ coll.find({str: "foo", ts: {$gte: Timestamp(1000, 1)}})
+ .addOption(DBQuery.Option.oplogReplay)
+ .itcount());
+ }
// Find should return correct results for query containing $expr when no collation specified and
// collection has a default collation.
@@ -759,22 +762,25 @@
assert.eq(null, planStage);
// Find with oplog replay should return correct results when "simple" collation specified
- // and collection has a default collation.
- coll.drop();
- assert.commandWorked(db.createCollection(
- coll.getName(),
- {collation: {locale: "en_US", strength: 2}, capped: true, size: 16 * 1024}));
- const t0 = Timestamp(1000, 0);
- const t1 = Timestamp(1000, 1);
- const t2 = Timestamp(1000, 2);
- assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 0)}));
- assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 1)}));
- assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 2)}));
- assert.eq(0,
- coll.find({str: "foo", ts: {$gte: Timestamp(1000, 1)}})
- .addOption(DBQuery.Option.oplogReplay)
- .collation({locale: "simple"})
- .itcount());
+ // and collection has a default collation. Skip this test for the mobile SE because it
+ // doesn't support capped collections which are needed for oplog replay.
+ if (jsTest.options().storageEngine !== "mobile") {
+ coll.drop();
+ assert.commandWorked(db.createCollection(
+ coll.getName(),
+ {collation: {locale: "en_US", strength: 2}, capped: true, size: 16 * 1024}));
+ const t0 = Timestamp(1000, 0);
+ const t1 = Timestamp(1000, 1);
+ const t2 = Timestamp(1000, 2);
+ assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 0)}));
+ assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 1)}));
+ assert.writeOK(coll.insert({str: "FOO", ts: Timestamp(1000, 2)}));
+ assert.eq(0,
+ coll.find({str: "foo", ts: {$gte: Timestamp(1000, 1)}})
+ .addOption(DBQuery.Option.oplogReplay)
+ .collation({locale: "simple"})
+ .itcount());
+ }
}
// Find should select compatible index when no collation specified and collection has a default
@@ -2001,16 +2007,22 @@
coll.find({_id: "foo"}).toArray(),
"query should have performed a case-insensitive match");
- assert.commandWorked(db.runCommand({
+ var cloneCollOutput = db.runCommand({
cloneCollectionAsCapped: coll.getName(),
toCollection: clonedColl.getName(),
size: 4096
- }));
- const clonedCollectionInfos = db.getCollectionInfos({name: clonedColl.getName()});
- assert.eq(clonedCollectionInfos.length, 1, tojson(clonedCollectionInfos));
- assert.eq(originalCollectionInfos[0].options.collation,
- clonedCollectionInfos[0].options.collation);
- assert.eq([{_id: "FOO"}], clonedColl.find({_id: "foo"}).toArray());
+ });
+ if (jsTest.options().storageEngine === "mobile") {
+ // Capped collections are not supported by the mobile storage engine
+ assert.commandFailedWithCode(cloneCollOutput, ErrorCodes.InvalidOptions);
+ } else {
+ assert.commandWorked(cloneCollOutput);
+ const clonedCollectionInfos = db.getCollectionInfos({name: clonedColl.getName()});
+ assert.eq(clonedCollectionInfos.length, 1, tojson(clonedCollectionInfos));
+ assert.eq(originalCollectionInfos[0].options.collation,
+ clonedCollectionInfos[0].options.collation);
+ assert.eq([{_id: "FOO"}], clonedColl.find({_id: "foo"}).toArray());
+ }
}
// Test that the find command's min/max options respect the collation.