-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
GroupBy with outer reference not translating properly, causing data loss #27102
Comments
Earlier, we didn't match on exact predicate Also fix bug in LikeExpression.Equals Resolves #27102
Generated SQL after fix SELECT [t].[Value] AS [A], (
SELECT MAX([t0].[Id])
FROM [Table] AS [t0]
WHERE ([t0].[Value] = ((
SELECT MAX([t1].[Id])
FROM [Table] AS [t1]
WHERE ([t].[Value] = [t1].[Value]) OR ([t].[Value] IS NULL AND [t1].[Value] IS NULL)) * 6)) OR ([t0].[Value] IS NULL AND (
SELECT MAX([t1].[Id])
FROM [Table] AS [t1]
WHERE ([t].[Value] = [t1].[Value]) OR ([t].[Value] IS NULL AND [t1].[Value] IS NULL)) IS NULL)) AS [B]
FROM [Table] AS [t]
GROUP BY [t].[Value] |
Is the query complexity due to This may have some perf issues since the base query is repeated in the subquery. Edit/clarification: SELECT [t].[Value] AS [A], (
SELECT MAX([t0].[Id])
FROM [Table] AS [t0]
WHERE ([t0].[Value] = (
SELECT MAX([t1].[Id])
FROM [Table] AS [t1]
WHERE [t].[Value] = [t1].[Value]) * 6)) AS [B]
FROM [Table] AS [t]
GROUP BY [t].[Value] |
|
Earlier, we didn't match on exact predicate Also fix bug in LikeExpression.Equals Resolves #27102
Some query logic is optimized away in the following query. No exception is thrown, the query executes successfully, returns the correct shape but bad data. This is a regression, it used to work in EF Core 5.
Possibly related to #27094.
Repro
Expected translation (approx):
Actual translation:
provider and version information
EF Core version: 6.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer 6.0.1
Target framework: .NET 6.0
Operating system: Windows 10 21H1
IDE: Visual Studio 2022 17.0.4
The text was updated successfully, but these errors were encountered: