[CSHARP-3421] LINQ3: Translate string IndexOf and IndexOfAny in filters Created: 10/Feb/21  Updated: 28/Oct/23  Resolved: 04/Oct/21

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

Type: Task Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CSHARP-3404 LINQ3: Get LegacyPredicateTranslatorT... Closed
Epic Link: CSHARP-2608

 Description   

See tests in LegacyPredicateTranslatorTests for details of how they should be translated.



 Comments   
Comment by Robert Stam [ 30/Mar/21 ]

Done but not reviewed

Comment by Robert Stam [ 30/Mar/21 ]

Reopened as we have decided to translate string expressions in filters to regular expressions the same as the existing LINQ implementation does.

Comment by Robert Stam [ 30/Mar/21 ]

astanton1978@gmail.com for the new LINQ implementation we are supporting the following values for the `comparisonType` parameter:

`CurrentCulture`: essentially a no-op as this is the server default

`CurrentCultureIgnoreCase`: results in the `i` flag being added to the regular expression

We don't support any other values for the `comparisonType` parameter because there is no way to tell the server to use a different culture for just one string comparison. The closest thing the server has support for is to the set "collation" for the entire aggregation pipeline.

Comment by Robert Stam [ 15/Feb/21 ]

We're still trying to decide how to map C# `StringComparison` values to supported MongoDB server-side functionality.

The server only lets you specify a collation for the entire operation, not for individual string comparisons.

Comment by Andrew Stanton [ 14/Feb/21 ]

@Robert Stam - does this handle the `StringComparison` enum choices (at least for OrdinalIgnoreCase)? I tried to find a PR for this to answer for myself but I didn't see one.  Another user created CSHARP-3425 and a PR to handle a `string.Equals` comparison but they were calling .`.ToLower()` first and that seemed unnecessary.  The c# driver documentation and examples dont cover casing of data.  Sorry if this isnt the right place to ask. 

Comment by Robert Stam [ 10/Feb/21 ]

Done but not reviewed

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