dbeaver/dbeaver#40639 Quote alias to prevent it's treated as keyword in query#41007
dbeaver/dbeaver#40639 Quote alias to prevent it's treated as keyword in query#41007HellAmbro wants to merge 3 commits intodbeaver:develdbeaver/dbeaver:develfrom HellAmbro:dbeaver/dbeaver#40639HellAmbro/dbeaver:dbeaver/dbeaver#40639Copy head branch name to clipboard
Conversation
| SelectItem<?> sei = new SelectItem<>(expression); | ||
| if (useAliasForColumns) { | ||
| sei.setAlias(new Alias(funcAliases[i])); | ||
| sei.setAlias(new Alias(SQLUtils.quoteString(dataSource, funcAliases[i]))); |
There was a problem hiding this comment.
I think it's weird. We generate this alias, and we can generate an alias that does not match a keyword.
I believe we need to modify the makeGroupFunctionAlias method so it generates a non-conflicting alias name. Take a look at generateEntityAlias (SQLUtils:824) method for the example implementation.
There was a problem hiding this comment.
Hi, thanks for the review. Your advice was very helpful. I know it was a straightforward solution, both for keeping the column named COUNT and for treating potential keywords as identifiers. However, I modified the makeGroupFunctionAlias method as suggested; now, when an alias is a keyword, a suffix is added. I tried to keep everything as close to the original code with minimal changes. I think there’s still space for improvement. I’ve also attached a screenshot to see the result.

|
@ShadelessFox thanks. I forgot to move it inside the if statement. |
|
Thanks. Passing to QA |
Closes #40639