summaryrefslogtreecommitdiff
path: root/jstests/core/collation.js
diff options
context:
space:
mode:
authorIan Boros <puppyofkosh@gmail.com>2019-04-04 19:20:35 -0400
committerIan Boros <puppyofkosh@gmail.com>2019-04-11 18:34:10 -0400
commit502df279c7476c01758ab210728f4acc4a27a218 (patch)
treef350da86174a673c792ca99e16ae43a0319e71c8 /jstests/core/collation.js
parentd131d7861c73efe052c5909ae8f1452c100a461d (diff)
downloadmongo-502df279c7476c01758ab210728f4acc4a27a218.tar.gz
SERVER-39567 Change find min/max options to require hint
Diffstat (limited to 'jstests/core/collation.js')
-rw-r--r--jstests/core/collation.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/jstests/core/collation.js b/jstests/core/collation.js
index ba5cab6f282..c4dc36fb914 100644
--- a/jstests/core/collation.js
+++ b/jstests/core/collation.js
@@ -1951,20 +1951,23 @@
assert.writeOK(coll.insert({str: "D"}));
// This query should fail, since there is no index to support the min/max.
- assert.throws(() => coll.find()
- .min({str: "b"})
- .max({str: "D"})
- .collation({locale: "en_US", strength: 2})
- .itcount());
+ let err = assert.throws(() => coll.find()
+ .min({str: "b"})
+ .max({str: "D"})
+ .collation({locale: "en_US", strength: 2})
+ .itcount());
+ assert.commandFailedWithCode(err, 51173);
// Even after building an index with the right key pattern, the query should fail since the
// collations don't match.
assert.commandWorked(coll.createIndex({str: 1}, {name: "noCollation"}));
- assert.throws(() => coll.find()
- .min({str: "b"})
- .max({str: "D"})
- .collation({locale: "en_US", strength: 2})
- .itcount());
+ err = assert.throws(() => coll.find()
+ .min({str: "b"})
+ .max({str: "D"})
+ .collation({locale: "en_US", strength: 2})
+ .hint({str: 1})
+ .itcount());
+ assert.commandFailedWithCode(err, 51174);
// After building an index with the case-insensitive US English collation, the query should
// work. Furthermore, the bounds defined by the min and max should respect the
@@ -1976,6 +1979,7 @@
.min({str: "b"})
.max({str: "D"})
.collation({locale: "en_US", strength: 2})
+ .hint("withCollation")
.itcount());
// Ensure results from index with min/max query are sorted to match requested collation.