-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 8.2.4, 8.2.6, 8.2.12
-
Component/s: None
-
None
-
Query Execution
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
A query using $expr with $in compares strings exactly, ignoring any collation supplied with the query. A case insensitive collation therefore misses documents that differ only in case, and the query still succeeds.
Substituting $eq for $in in the same $expr gives the correct result, as does the ordinary $in form outside $expr, so neither the collation nor $expr is at fault on its own.
An index on the field makes no difference. A collection default collation behaves the same as a collation passed with the query.
7.0.31 applies the collation correctly here, so this changed somewhere in 8.x.
Nothing fails, which is what makes it easy to miss. The query succeeds and the documents it returns look reasonable, so an application would quietly see fewer results than it asked for.
Expected
Every document matching under the collation, which is all three in the reproduction steps.
Actual
Only the document matching exact case, with no error and nothing logged.