Skip to content
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

Fix inference issues around convert to object #21125

Merged
merged 6 commits into from
Jun 13, 2020
Merged

Fix inference issues around convert to object #21125

merged 6 commits into from
Jun 13, 2020

Conversation

roji
Copy link
Member

@roji roji commented Jun 3, 2020

Fixes #19688

@roji roji requested review from smitpatel and maumar June 3, 2020 13:26
Copy link
Member

@smitpatel smitpatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is fixing cases like
(Convert(b.Name, Object) == null) &
(object)c.City == (object)"London"
Then it should normalize it during SqlTranslator.VisitBinary method by removing object convert from both sides (or from one side if other side is null).

Also apply same thing to Cosmos.

@roji roji requested a review from smitpatel June 12, 2020 22:00
@@ -884,37 +947,6 @@ private SqlExpression BindProperty(EntityReferenceExpression entityReferenceExpr
throw new InvalidOperationException(CoreStrings.TranslationFailed(methodCallExpression.Print()));
}

private static Expression TryRemoveImplicitConvert(Expression expression)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to move this to local function? This is not specific to BinaryExpression.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't used anywhere else so I did it... We can always move it out if it's needed no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need to remember that we had method like this hiding here.
Local methods which are valid in a context of a particular method makes sense but not used elsewhere hence local could be bit non-productive.

cc: @dotnet/efcore ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to bother everyone, I'll just move it out if that's what you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a usecase, there RemoveObjectConvert in VisitMethodCall too. You can DRY with TryUnwrapConvertToObject

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In VisitBinary we need to know if we unwrapped or not (hence Try*), but in VisitMethodCall we don't (so it returns the unwrapped)... So DRYing would make VisitMethodCall clunkier (calling Try* and testing the result). Let's leave things the way they are, the code fragment is really small...

However I did DRY out RemoveObjectConvert in Relational which is used by both VisitMethodCall and ConvertObjectArrayEqualityComparison.

@roji roji requested a review from smitpatel June 12, 2020 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The LINQ expression 'Is Nothing' could not be translated VB.NET
2 participants