diff options
author | Ian Boros <puppyofkosh@gmail.com> | 2019-04-04 19:20:35 -0400 |
---|---|---|
committer | Ian Boros <puppyofkosh@gmail.com> | 2019-04-11 18:34:10 -0400 |
commit | 502df279c7476c01758ab210728f4acc4a27a218 (patch) | |
tree | f350da86174a673c792ca99e16ae43a0319e71c8 /jstests/core/collation.js | |
parent | d131d7861c73efe052c5909ae8f1452c100a461d (diff) | |
download | mongo-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.js | 24 |
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. |