提交 001de1a3 编写于 作者: A Alexey Milovidov

Always backquote column names in CREATE/ATTACH queries

上级 ad6648af
......@@ -41,7 +41,9 @@ void ASTColumnDeclaration::formatImpl(const FormatSettings & settings, FormatSta
frame.need_parens = false;
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
settings.ostr << settings.nl_or_ws << indent_str << backQuoteIfNeed(name);
/// We have to always backquote column names to avoid ambiguouty with INDEX and other declarations in CREATE query.
settings.ostr << settings.nl_or_ws << indent_str << backQuote(name);
if (type)
{
settings.ostr << ' ';
......
......@@ -25,7 +25,6 @@ const char * IAST::hilite_alias = "\033[0;32m";
const char * IAST::hilite_none = "\033[0m";
/// Quote the identifier with backquotes, if required.
String backQuoteIfNeed(const String & x)
{
String res(x.size(), '\0');
......@@ -36,6 +35,16 @@ String backQuoteIfNeed(const String & x)
return res;
}
String backQuote(const String & x)
{
String res(x.size(), '\0');
{
WriteBufferFromString wb(res);
writeBackQuotedString(x, wb);
}
return res;
}
size_t IAST::checkSize(size_t max_size) const
{
......
......@@ -208,7 +208,9 @@ private:
};
/// Surrounds an identifier by back quotes if it is necessary.
/// Quote the identifier with backquotes, if required.
String backQuoteIfNeed(const String & x);
/// Quote the identifier with backquotes.
String backQuote(const String & x);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册