-
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 FK_Id.HasValue on Sql Server generates invalid sql #15641
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
punted-for-3.0
type-bug
Milestone
Comments
While looking for a workaround I also hit this;
Which generated;
Where the intermediate value shouldn't be named. And finally discovered that this does work;
And generates straight forward SQL. Though the result set is obviously an int instead of bool, I can live with that for now. |
Generated SQL in 3.1 SELECT CASE
WHEN [t].[FKId] IS NOT NULL THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END AS [HasValue]
FROM [Table] AS [t]
GROUP BY CASE
WHEN [t].[FKId] IS NOT NULL THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END 2nd query gets SELECT CASE
WHEN CASE
WHEN [t].[FKId] IS NOT NULL THEN 1
ELSE 0
END = 1 THEN CAST(1 AS bit)
ELSE CAST(0 AS bit)
END AS [HasValue]
FROM [Table] AS [t]
GROUP BY CASE
WHEN [t].[FKId] IS NOT NULL THEN 1
ELSE 0
END |
maumar
added a commit
that referenced
this issue
Jan 24, 2020
…tes invalid sql The issue has been fixed earlier. Resolves #15641
maumar
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Jan 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
punted-for-3.0
type-bug
Generates invalid Sql;
And fails;
Generating the same case statement in the group by would fix it.
EF Core version: 2.2.3
Database Provider: Sql Server
The text was updated successfully, but these errors were encountered: