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

Query: Incorrect syntax near the keyword 'AS` for group by aggregate #12826

Closed
smitpatel opened this issue Jul 27, 2018 · 9 comments · Fixed by #21077
Closed

Query: Incorrect syntax near the keyword 'AS` for group by aggregate #12826

smitpatel opened this issue Jul 27, 2018 · 9 comments · Fixed by #21077
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 punted-for-3.1 type-bug
Milestone

Comments

@smitpatel
Copy link
Member

Actual Title Query: Define a transport mechanism for binding Key/ElementSelector for GroupBy Aggregate

We currently use MemberInfoProjectionMapping, which was designed to be used for things which are added to projection. And whenever it is referenced it would come from inner subquery.

We started reusing it for GroupBy Aggregate case since we treat element selector same as select clause. Which causes a lot of incorrect SQL.

Filing a general issue and closing all issues failing with this.

@smitpatel
Copy link
Member Author

Dependent on #12089

@sam-wheat
Copy link

sam-wheat commented Aug 3, 2018

Perhaps covered by one of the other issues but I will add this for reference:

var xresult = db.Comments.GroupBy(x => x.ID)
			.Select(x => new { k = x.Key.ToString(), v = x.Key.ToString() }).ToList();

Copied from profiler:

SELECT CONVERT(VARCHAR(20), [x].[ID] AS [Key]) AS [v]
FROM [Comments] AS [x]
GROUP BY [x].[ID]

Exception: Incorrect syntax near the keyword 'AS'.

EF Core 2.1.1

@ajcvickers
Copy link
Member

Discuss in triage 🇦🇺

@elAndyG
Copy link

elAndyG commented Sep 28, 2018

I receive the same Sql structure as @sam-wheat, but when using x.Key.PropertyName.ToUpper() and x.Key.PropertyName.ToUpper() ?? "Unknown Property"

@jag43
Copy link

jag43 commented Sep 30, 2018

Is there an ETA for this?

@smitpatel
Copy link
Member Author

For test look all the closed referenced issue to cover all the scenarios.

@smitpatel
Copy link
Member Author

@maumar - What is pending on this issue?

@maumar
Copy link
Contributor

maumar commented Nov 11, 2019

haven't added any tests yet, but we can/should do this in 5.0

@ajcvickers ajcvickers modified the milestones: Backlog, 5.0.0 Nov 13, 2019
maumar added a commit that referenced this issue May 29, 2020
… keyword 'AS` for group by aggregate

Resolves #12826
@maumar maumar added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed verify-fixed This issue is likely fixed in new query pipeline. labels May 29, 2020
maumar added a commit that referenced this issue Jun 17, 2020
… keyword 'AS` for group by aggregate

Resolves #12826
maumar added a commit that referenced this issue Jun 17, 2020
… keyword 'AS` for group by aggregate

Resolves #12826
@maumar maumar closed this as completed in 1370d57 Jun 19, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0, 5.0.0-preview7 Jun 22, 2020
@ajcvickers ajcvickers modified the milestones: 5.0.0-preview7, 5.0.0 Nov 7, 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. punted-for-3.0 punted-for-3.1 type-bug
Projects
None yet
6 participants