[CSHARP-2557] Change in behaviour of parsing nested .Any predicates Created: 21/Mar/19  Updated: 28/Oct/23  Resolved: 08/Apr/19

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.8.0
Fix Version/s: 2.8.1

Type: Bug Priority: Blocker - P1
Reporter: Kevin Fairs Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CSHARP-2574 $elemMatch query contains gaps when I... Closed
Backwards Compatibility: Major Change

 Description   

Hello

I have 2 classes:

public class Donation    

{                public ObjectId Id \{ get; set; }
        public ICollection<Item> Items { get; set; }

}

public class Item    
{                public ObjectId Id { get; set; }

        public ICollection<ObjectId> ParentIds { get; set; }

}

Example Data:

{   

     "_id" : ObjectId("553682b4ecab640ee4ba35e5"),       

     "Items" : [        

                       

{     "_id" : ObjectId("553682b4ecab640ee4ba35e6"),                              "ParentIds" : [                                                     ObjectId("55368285ecab640eb8d6976f"),                                     ObjectId("55368256ecab640eb8d6976e"),                                      ObjectId("55016c84b9e76f04a8821be5")                                          ]                              }

    ]}

 

I have the following c# predicate:
find(x => x.Items.Any(d => d.ParentIds.Any(p => p == ObjectId("55368256ecab640eb8d6976e"))))

 

V2.7.3 behaviour emits:

.find({ "Items.ParentIds" : ObjectId("55368256ecab640eb8d6976e") })

 

V.2.8.0 behaviour emits:

.find({ "Items.ParentIds" : { "$elemMatch" :

{ "" : ObjectId("55368256ecab640eb8d6976e") }

} })

 

This breaks our production build, working happily for several years now....

 

Thanks

 

 



 Comments   
Comment by Githook User [ 06/Apr/19 ]

Author:

{'email': 'dmitry_lukyanov@epam.com', 'name': 'Dmitry Lukyanov', 'username': 'dmitry-lukyanov'}

Message: CSHARP-2557: Fix bug in '$elemMatch' generating if expression predicate contains `DocumentsExpression`s as an operand.
Branch: v2.8.x
https://github.com/mongodb/mongo-csharp-driver/commit/327b17c5d498b8a9e825f1ca9bc7c442a6a61179

Comment by Githook User [ 05/Apr/19 ]

Author:

{'name': 'Dmitry Lukyanov', 'username': 'dmitry-lukyanov', 'email': 'dmitry_lukyanov@epam.com'}

Message: CSHARP-2557: Fix bug in '$elemMatch' generating if expression predicate contains `DocumentsExpression`s as an operand.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/0cb2c311b846382d6b7ffd6082c361b7220cf0fc

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