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

Sql generation improvements #4164

Closed
ryanlin1986 opened this issue Dec 23, 2015 · 7 comments
Closed

Sql generation improvements #4164

ryanlin1986 opened this issue Dec 23, 2015 · 7 comments

Comments

@ryanlin1986
Copy link

select it.Name from Customer as it
instead of
select it.[Name] as [Name] from Customer as it
Two points:
#1, as [Name] is not necessary in this scenario.
#2, it.[Name] should be it.Name, since Name is not a keyword, I think it's better to maintain a keywords list and only use [] for keywords.

This will decrease the generated sql and much readable.

@leus
Copy link

leus commented Dec 24, 2015

How do you detemine "Name" is not a keyword in all different supported databases, today and in the future?

@ryanlin1986
Copy link
Author

Like I said, the keywords list should be maintained, and when new database version comes out, we updated the keywords list with updated provider version.

@leus
Copy link

leus commented Dec 25, 2015

Sound like a helluva lot of work for very little gain to me.

@rowanmiller
Copy link
Contributor

Is there any value in not escaping the names? I don't think it would make any difference to the plan compiler in SQL Server. I think you could also argue that it's easier to read if everything is enclosed in [].

Avoiding aliasing with the same name sounds like a reasonable simplification.

@ryanlin1986
Copy link
Author

Thanks, maybe I was wrong about the alias without [], I guess it's not worth to do this.
So my only question is the #1.

@rowanmiller
Copy link
Contributor

@ryanlin1986 can you share a code listing that demonstrates where you are seeing the unneeded aliasing happening? In general we don't do this, but maybe you have found a case where we do.

For example, here is a query we generate from RC1-final

SELECT [b].[BlogId], [b].[Created], [b].[Url]
FROM [Blog] AS [b]
ORDER BY [b].[Url]

@ryanlin1986
Copy link
Author

@rowanmiller RC1-final is just fine, maintain the keywords list is not worth it, since RC-1 does this well, I close this now.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
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

No branches or pull requests

4 participants