Treat PROJECTION, DICTIONARY, COLUMN, INDEX names as identifiers when formating

This commit is contained in:
Tuan Pham Anh 2024-08-26 15:26:21 +00:00
parent 5bad631d46
commit d6ca589ebe
5 changed files with 5 additions and 6 deletions

View File

@ -59,7 +59,7 @@ static std::initializer_list<std::pair<ClickHouseVersion, SettingsChangesHistory
{
{"24.12",
{
{"output_format_identifier_quoting_style", 1, 1, "New setting."}
{"output_format_identifier_quoting_style", "Backticks", "Backticks", "New setting."}
}
},
{"24.12",

View File

@ -66,8 +66,7 @@ void ASTColumnDeclaration::formatImpl(const FormatSettings & format_settings, Fo
{
frame.need_parens = false;
/// We have to always backquote column names to avoid ambiguity with INDEX and other declarations in CREATE query.
format_settings.ostr << backQuote(name);
format_settings.writeIdentifier(name);
if (type)
{

View File

@ -35,7 +35,7 @@ void ASTDictionaryAttributeDeclaration::formatImpl(const FormatSettings & settin
{
frame.need_parens = false;
settings.ostr << backQuote(name);
settings.writeIdentifier(name);
if (type)
{

View File

@ -79,7 +79,7 @@ void ASTIndexDeclaration::formatImpl(const FormatSettings & s, FormatState & sta
}
else
{
s.ostr << backQuoteIfNeed(name);
s.writeIdentifier(name);
s.ostr << " ";
expr->formatImpl(s, state, frame);
}

View File

@ -17,7 +17,7 @@ ASTPtr ASTProjectionDeclaration::clone() const
void ASTProjectionDeclaration::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
settings.ostr << backQuoteIfNeed(name);
settings.writeIdentifier(name);
std::string indent_str = settings.one_line ? "" : std::string(4u * frame.indent, ' ');
std::string nl_or_nothing = settings.one_line ? "" : "\n";
settings.ostr << settings.nl_or_ws << indent_str << "(" << nl_or_nothing;