-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Using the latest C# driver version (2.13.1) and latest MongoDB community server version (5.0.2).
Trying to use where in projection yields an incorrect query (besides the already reported issue from CSHARP-3783 GroupJoin with projection yields incorrect query - MongoDB Jira).
In the example below showing how the driver translated c.Where(ch => ch.ParentLevel == p.Level).All(ch => ch.Status == p.Status), you can see it effectively translated into c.All(ch => ch.ParentLevel == p.Level && ch => ch.Status == p.Status) which is not equivalent logic.
ChildrenConsistent = (c.Any(ch => ch.ParentLevel == p.Level) || p.Status == SerialStatus.Destroyed) && c.Where(ch => ch.ParentLevel == p.Level).All(ch => ch.Status == p.Status)
{
"ChildrenConsistent":{
"$and":[
{
"$or":[
{
"$anyElementTrue":{
"$map":{
"input":"$c",
"as":"ch",
"in":{
"$eq":[
"$$ch.ParentLevel",
"$$ch.Level"
]
}
}
}
},
{
"$eq":[
"$Status",
5
]
}
]
},
{
"$allElementsTrue":{
"$map":{
"input":"$c",
"as":"ch",
"in":{
"$and":[
{
"$eq":[
"$$ch.ParentLevel",
"$$ch.Level"
]
},
{
"$eq":[
"$$ch.Status",
"$$ch.Status"
]
}
]
}
}
}
}
]
}
}
- duplicates
-
CSHARP-3783 GroupJoin with projection yields incorrect query
-
- Closed
-