-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSHARP-5473: Provide API to turn LINQ expression into MQL. #1601
base: main
Are you sure you want to change the base?
Conversation
public class CSharp5473Tests : Linq3IntegrationTest | ||
{ | ||
[Fact] | ||
public void Select_decimal_divide_should_work() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor : Test method name seems to be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
var stages = provider.Translate(queryable, out var outputSerializer); | ||
AssertStages(stages, "{ $project : { _v : { $add : ['$X', 1] }, _id : 0 } }"); | ||
|
||
var result = queryable.First(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we try to execute translated MQL in some way instead to make sure the translation was done properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but not necessarily to verify that the translation was done correctly.
I'm more interested in showing HOW you could execute the result of Translate
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM + minor question.
@@ -152,5 +153,14 @@ public override ExpressionTranslationOptions GetTranslationOptions() | |||
var database = _database ?? _collection?.Database; | |||
return translationOptions.AddMissingOptionsFrom(database?.Client.Settings.TranslationOptions); | |||
} | |||
|
|||
public override BsonDocument[] Translate<TResult>(IQueryable<TResult> queryable, out IBsonSerializer<TResult> outputSerializer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if provided queryable is MongoDB queryable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe receiving an expression is sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be sufficient.
I chose IQueryable
to emphasize that it's the Expression
associated with an IQueryable
that is being translated, not any old expression.
But the .NET method takes an Expression
, so we could also here.
@damieng what do you think?
I think if we want to ship this for now we should use the Alternatively I could use reflection to do the same sort of thing on the already-released version and make sure it meets our use cases on the EF provider before shipping. |
You are the one that asked for this. If you are not sure it does what you need then we shouldn't ship it yet. |
The BIG question for this PR is whether we want to do this at all, and if so what the public API should be.