[CSHARP-4500] $not on inner array of strings renders invalid query with LINQ3 LinqProvider Created: 30/Jan/23  Updated: 28/Oct/23  Resolved: 09/Mar/23

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

Type: Bug Priority: Unknown
Reporter: DanikRaikhlin N/A Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed
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

Behaviour changed on how the following linq query is parsed:

 

collection
    .AsQueryable()
    .Where(x => !x.List.Any(xx => xx.ToLower().Contains(input.ToLower())))
    .ToString(); 

 

Wrong query MongoDB.Driver (2.19.0):

 

 { "$match" : { "List" : { "$not" : { "$elemMatch" : /string/is } } } } 

 

Expected and worked in MongoDB.Driver (2.18.0)

 

 

 { "$match" : { "List" : { "$not" : /string/is } } } 

 

 

This is only broken for a $not query. The folowing snippet works fine:

 

collection
    .AsQueryable()
    .Where(x => x.List.Any(xx => xx.ToLower().Contains(input.ToLower())))
    .ToString() 

{ "$match" : { "List" : /string/is } } 



 Comments   
Comment by Githook User [ 24/Mar/23 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4500: Move some simplifications from Render to AstSimplifier.
Branch: v2.19.x
https://github.com/mongodb/mongo-csharp-driver/commit/7cbae1eaac30f7af1499201d4deb16b2ea501c75

Comment by Githook User [ 09/Mar/23 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4500: Move some simplifications from Render to AstSimplifier.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/ca4d04eaedd6de4983585e082abe467088b65bbd

Comment by Robert Stam [ 30/Jan/23 ]

Thank you for reporting this.

I am able to reproduce the issue with the information provided and am investigating further.

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