MongoDB 5.0 returns incorrect results for queries of the form:
{ "a.0": { $exists: false } }
In MongoDB 4.4 and earlier, this would return documents where the field didn't contain an array. In MongoDB 5.0, all documents are returned even if the field contains an array.
Why does this matter? The .NET/C# driver uses this technique in its legacy LINQ implementation to determine whether a field contains a single value or an array - in particular for discriminators. Let's say we have a class D that derives from C and B. When we insert a document of type D, we will write the discriminator as {{ _t: [B,C,D] }}. If we want to find all B, but not any derived types such as C and D, we will generate the following query:
{ "_t.0" : { "$exists" : false }, _t : "B" }
When querying MongoDB 4.4 and earlier, we only get documents with _t: "B" back. When querying MongoDB 5.0, we get documents of type B, C, and D back.
While we can potentially fix this problem in the C# driver by using another technique, it will be a backwards breaking change for existing C# apps that may prevent them from upgrading to MongoDB 5.0.
- causes
-
CSHARP-3687 Fixing legacy LINQ tests on latest
- Closed
- is depended on by
-
CSHARP-3704 Temporarily disable tests failing due to SERVER-57300
- Closed