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

ExecuteDelete: Generate correct Contains method when query has unsupported operators #28755

Merged
merged 1 commit into from
Aug 17, 2022

Conversation

smitpatel
Copy link
Contributor

@smitpatel smitpatel commented Aug 16, 2022

Resolves #28745

@smitpatel smitpatel requested a review from a team August 16, 2022 22:09
@smitpatel smitpatel marked this pull request as draft August 17, 2022 00:46
@smitpatel smitpatel changed the base branch from release/7.0-rc1 to release/7.0 August 17, 2022 00:46
@smitpatel
Copy link
Contributor Author

smitpatel commented Aug 17, 2022

Blocked on #28752

worked-around

{
protected override string StoreName => "NonSharedModelBulkUpdatesTests";

#nullable enable
Copy link
Member

Choose a reason for hiding this comment

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

No problem with this, but any particular reason to turn this on for this particular test? I hope to do a pass and turn on NRTs on at least some of our tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original repro had it, in order to avoid any unrelated differences from repro to creep in and potentially making the test pass even though the original issue wasn't fixed, just added it. I think it is ok to add nullable when required in tests especially query tests because LINQ loves NRTs.

@@ -1082,7 +1082,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
if (pk.Properties.Count == 1)
{
predicateBody = Expression.Call(
QueryableMethods.Contains.MakeGenericMethod(clrType), source, entityParameter);
EnumerableMethods.Contains.MakeGenericMethod(clrType), source, entityParameter);
Copy link
Member

Choose a reason for hiding this comment

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

BTW, if didn't have the special condition for pk.Property.Count == 1, and just went through the flow below (constructing AnyWithPredicate instead of Contains), wouldn't that still get picked up as entity equality and do the right thing? In general, I thought we treat blogs.Contains(blog) and blogs.Any(b => b == blog) in the same way.

(not blocking for merging this, just a question)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They generate different SQL. But more-or-less same output. But this gives a good idea for this PR that, we can just fallback to Any code path for now and improve this later (post rc1)

@@ -1082,7 +1082,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
if (pk.Properties.Count == 1)
{
predicateBody = Expression.Call(
QueryableMethods.Contains.MakeGenericMethod(clrType), source, entityParameter);
EnumerableMethods.Contains.MakeGenericMethod(clrType), source, entityParameter);
Copy link
Member

Choose a reason for hiding this comment

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

Is it OK that here we use EnumerableMethods, but below with AnyWithPredicate we still use QueryableMethods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We don't translate Enumerable.Any.
Contains both variations can be translated. Though only enumerable code path deals with entity equality since it is inside sqltranslator.

@smitpatel smitpatel marked this pull request as ready for review August 17, 2022 17:35
@smitpatel smitpatel changed the base branch from release/7.0 to release/7.0-rc1 August 17, 2022 17:35
@smitpatel
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@smitpatel smitpatel merged commit 0a33473 into release/7.0-rc1 Aug 17, 2022
@smitpatel smitpatel deleted the smit/executebugs1 branch August 17, 2022 19:19
@ajcvickers ajcvickers changed the title ExecuteDelete: Generate correct Contains method when query has unsupp… ExecuteDelete: Generate correct Contains method when query has unsupported operators Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExecuteDelete with optional reference navigation in filter fails with SQLite
3 participants