[CSHARP-4561] Version 2.19 breaks ToUpper comparison Created: 06/Mar/23  Updated: 27/Oct/23  Resolved: 06/Mar/23

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: 2.19.0
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Martin Oehlert Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

With the latest version of the mongo db c# driver and linq3, the expression comparison of a string value with the call of a ToUpper is broken.

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

How to Reproduce

I want create a dynamic query and create a query expression like this

item => ((item.StringValue != null) AndAlso item.StringValue.ToUpper().Contains("foo"))

which then translate into this

database.collection.Aggregate([{ "$match" : { "$and" : [{ "stringValue" :

{ "$ne" : null }

}, { "_id" :

{ "$type" : -1 }

}] } }])

Additional Background

-



 Comments   
Comment by Robert Stam [ 06/Mar/23 ]

`item.StringValue.ToUpper().Contains("foo")` can never be true.

A condition that can never be true translates to `{ _id :

{ $type : -1 }

}`, which is an MQL filter that can never match anything.

 

Generated at Wed Feb 07 21:48:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.