Skip to content

Commit 7f2ce4a

Browse files
committed
CSHARP-1734: fixing issue related to nested Any clauses with conjunctions.
1 parent 444e1aa commit 7f2ce4a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/MongoDB.Driver/Linq/Translators/PredicateTranslator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,11 @@ protected internal override Expression VisitDocument(DocumentExpression node)
16281628
{
16291629
return new FieldExpression("", node.Serializer);
16301630
}
1631+
1632+
protected internal override Expression VisitPipeline(PipelineExpression node)
1633+
{
1634+
return node;
1635+
}
16311636
}
16321637
}
16331638
}

tests/MongoDB.Driver.Tests/Linq/Translators/PredicateTranslatorTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ public void Any_with_a_nested_Any()
135135
x => x.G.Any(g => g.S.Any(s => s.D == "Delilah")),
136136
1,
137137
"{\"G.S.D\": \"Delilah\"}");
138+
139+
Assert(
140+
x => x.G.Any(g => g.D == "Don't" && g.S.Any(s => s.D == "Delilah")),
141+
1,
142+
"{G: {$elemMatch: {D: \"Don't\", \"S.D\": \"Delilah\" }}}");
143+
144+
Assert(
145+
x => x.G.Any(g => g.D == "Don't" && g.S.Any(s => s.E == null && s.D == "Delilah")),
146+
1,
147+
"{G: {$elemMatch: {D: \"Don't\", \"S\": {$elemMatch: {E: null, D: \"Delilah\" }}}}}");
138148
}
139149

140150
[Fact]

0 commit comments

Comments
 (0)