CSHARP-5658: Convert value type to match field serializer type in Equals filter translation#1981
CSHARP-5658: Convert value type to match field serializer type in Equals filter translation#1981kyra-rk wants to merge 5 commits into
Conversation
|
Other filter translators have the same
If this fix looks good, it might be worth extracting the conversion into a shared helper and applying it to these as well. |
There was a problem hiding this comment.
Pull request overview
Adds support for translating Equals filters when the constant value’s CLR type differs from the field serializer’s value type (notably numeric/nullable numeric scenarios), and introduces integration tests covering the regression.
Changes:
- Update
EqualsMethodToFilterTranslatorto coerce constant values to the field serializer’sValueTypebefore serialization. - Add LINQ integration tests for
Nullable<int>fields compared againstulong,int, andnull, including a no-match case.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/MethodTranslators/EqualsMethodToFilterTranslator.cs |
Adds a pre-serialization constant conversion step based on the field serializer value type. |
tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/MethodTranslators/EqualsMethodToFilterTranslatorTests.cs |
New integration tests validating translation/output for Equals with numeric and null constants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var exception = Record.Exception(() => filter.Render(__args)); | ||
| exception.Should().NotBeNull(); |
|
Hey @adelinowona, I took over Kyra for this ticket. What do you think of the approach? |
No description provided.