fix bugs (now tests pass)

This commit is contained in:
natasha 2023-03-15 21:20:56 +00:00
parent da5285004d
commit ed22d0f028
6 changed files with 11 additions and 4 deletions

View File

@ -161,8 +161,8 @@ void ASTDictionary::formatImpl(const FormatSettings & settings, FormatState & st
if (source)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << settings.nl_or_ws << "SOURCE("
<< (settings.hilite ? hilite_none : "");
settings.ostr << (settings.hilite ? hilite_keyword : "") << settings.nl_or_ws << "SOURCE"
<< (settings.hilite ? hilite_none : "") << "(";
source->formatImpl(settings, state, frame);
settings.ostr << ")";
}

View File

@ -66,6 +66,8 @@ void ASTDictionaryAttributeDeclaration::formatImpl(const FormatSettings & settin
if (is_object_id)
settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "IS_OBJECT_ID";
settings.ostr << (settings.hilite ? hilite_none : "");
}
}

View File

@ -692,7 +692,7 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
{
std::string nl_or_nothing = settings.one_line ? "" : "\n";
std::string indent_str = settings.one_line ? "" : std::string(4u * frame.indent, ' ');
settings.ostr << (settings.hilite ? hilite_function : "") << name << "(" << nl_or_nothing;
settings.ostr << (settings.hilite ? hilite_function : "") << name << (settings.hilite ? hilite_none : "") << "(" << nl_or_nothing;
FormatStateStacked frame_nested = frame;
frame_nested.need_parens = false;
++frame_nested.indent;

View File

@ -29,11 +29,13 @@ void ASTKillQueryQuery::formatQueryImpl(const FormatSettings & settings, FormatS
break;
}
settings.ostr << (settings.hilite ? hilite_none : "");
formatOnCluster(settings);
if (where_expression)
{
settings.ostr << " WHERE " << (settings.hilite ? hilite_none : "");
settings.ostr << (settings.hilite ? hilite_keyword : "") << " WHERE " << (settings.hilite ? hilite_none : "");
where_expression->formatImpl(settings, state, frame);
}

View File

@ -20,7 +20,9 @@ void ASTWithAlias::formatImpl(const FormatSettings & settings, FormatState & sta
/// This is needed because the query can become extraordinary large after substitution of aliases.
if (!alias.empty() && !state.printed_asts_with_alias.emplace(frame.current_select, alias, getTreeHash()).second)
{
settings.ostr << (settings.hilite ? IAST::hilite_identifier : "");
settings.writeIdentifier(alias);
settings.ostr << (settings.hilite ? IAST::hilite_none : "");
}
else
{

View File

@ -18,6 +18,7 @@ void ASTWithElement::formatImpl(const FormatSettings & settings, FormatState & s
{
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
settings.ostr << (settings.hilite ? hilite_alias : "");
settings.writeIdentifier(name);
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS" << (settings.hilite ? hilite_none : "");
settings.ostr << settings.nl_or_ws << indent_str;