-
Notifications
You must be signed in to change notification settings - Fork 933
Evaluate parameter expression for Enumerable.Contains calls #2873
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Seems to be fixed by 15381b0 |
if (IsCollectionParameter(arg)) | ||
return true; | ||
|
||
return arg.NodeType == ExpressionType.Call && TryGetCollectionParameter((MethodCallExpression) arg); |
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.
Why do we need to do that recursively?
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.
To support chain of LINQ commands. And to make sure it doesn't start with mapped association (somethin like
db.Orders.Where( x => x.OrderLines.Select(...).Where(...).Contains(...))
should not be evaluated)
Imho, there is a bug in I made the tests working by copying EvaluatableTreeFindingExpressionVisitor to our codebase and modifying
There are some side effects (like lambdas are marked as evaluatable which it should not do, but it can be fixed further down the track) |
In other words the @v-kabanov's solution is more correct. Although I don't like it, because I believe it can be much simpler. |
return; | ||
|
||
if(TryGetCollectionParameter((MethodCallExpression)argument)) | ||
_partialEvaluationInfo.AddEvaluatableExpression(argument); |
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.
Here you're modifying external dependency, which you should not.
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.
I don't get it. Why I shouldn't touch it? It's just a wrapper around set of expressions that needs evaluation. I can store it in separate field (as I did initially) - but to minimize change noise I used already present class for storing evaluatable expressions.
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.
I don't get it. Why I shouldn't touch it?
Because this is the information provided by another concerning party. We already let this logic spread across solution and so we're trying to catch bugs doing 10th bugfix release. Let's avoid doing ad-hoc patches of logic here and there.
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.
Well.. Ok... It can be stored separately. But I still think it's more proper to store it in _partialEvaluationInfo
- external or not, it stores list of expressions that needs evaluation. So it's better to fill it also with our expressions - so all other external parties can handle it appropriately as evaluatable expression.
But before making any further changes - do you agree with this fix on principle?
With the proposed implementation following expression would be considered as evaluatable:
|
I agree. Though I don't like including another bunch of slightly modified files from Re-Linq. IMO better local small targeted fix. We can drop it if his Relinq PR is accepted re-motion/Relinq#14
Sounds like it can cause more regressions (at least more unnecessary attempts to compile) than my fix |
db.Orders.Where(o => ids.Where(i => i == o.OrderId).Contains(o.OrderId)) Yeah. I know.. But it's not supported anyway. Old behavior: New behavior: Exception is thrown: |
https://re-motion.atlassian.net/browse/RMLNQ-96 It looks like it's known limitation since 2016. And here is author's thoughts about @v-kabanov's fix: https://re-motion.atlassian.net/browse/RMLNQ-127?focusedCommentId=21851 |
After sleeping on the issue overnight, I think we should not fix it. Not at 5.3.x at least. I would prefer a fix of RMLNQ-96 in re-linq itself. |
Ok. I rebased it on top of master. |
Fixes #2872
Fixes #2276
Alternative for #2291. This fix specifically handles only
Contains
call on collection parameters. It minimizes changes and I think should suffice for our needs.Targeting it to 5.3 as "semi-broken" queries in 5.2 now throw exception (see #2872).