Better formatting of CREATE queries

This commit is contained in:
Alexey Milovidov 2020-06-15 07:27:33 +03:00
parent 1c5c2f8c69
commit e9eb722d4a
3 changed files with 6 additions and 2 deletions

View File

@ -197,6 +197,7 @@ ASTPtr ASTCreateQuery::clone() const
void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
frame.need_parens = false;
frame.expression_list_always_start_on_new_line = true;
if (!database.empty() && table.empty())
{

View File

@ -39,10 +39,12 @@ void ASTExpressionList::formatImplMultiline(const FormatSettings & settings, For
settings.ostr << separator;
}
if (children.size() > 1)
if (children.size() > 1 || frame.expression_list_always_start_on_new_line)
settings.ostr << indent_str;
(*it)->formatImpl(settings, state, frame);
FormatStateStacked frame_nested = frame;
frame_nested.expression_list_always_start_on_new_line = false;
(*it)->formatImpl(settings, state, frame_nested);
}
}

View File

@ -202,6 +202,7 @@ public:
{
UInt8 indent = 0;
bool need_parens = false;
bool expression_list_always_start_on_new_line = false; /// Line feed and indent before expression list even if it's of single element.
const IAST * current_select = nullptr;
};