fix misplaced ( in ASTCreateQuery.cpp

This commit is contained in:
natasha 2023-04-03 12:54:34 +01:00
parent e984e221ce
commit 264c129a96
2 changed files with 4 additions and 5 deletions

View File

@ -440,8 +440,8 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
if (select)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS"
<< (comment ? "(" : "")
<< settings.nl_or_ws << (settings.hilite ? hilite_none : "");
<< settings.nl_or_ws
<< (comment ? "(" : "") << (settings.hilite ? hilite_none : "");
select->formatImpl(settings, state, frame);
settings.ostr << (settings.hilite ? hilite_keyword : "") << (comment ? ")" : "") << (settings.hilite ? hilite_none : "");
}

View File

@ -321,10 +321,9 @@ TEST(FormatHiliting, ASTKillQueryQuery)
TEST(FormatHiliting, ASTCreateQuery)
{
// The misplaced space around ( is on purpose, as this bug will fixed in a separate PR.
String query = "CREATE TABLE name AS( SELECT *) COMMENT 'hello'";
String query = "CREATE TABLE name AS (SELECT *) COMMENT 'hello'";
String expected = keyword("CREATE TABLE ") + "name " + keyword("AS( SELECT ") + "*" + keyword(") ")
String expected = keyword("CREATE TABLE ") + "name " + keyword("AS (SELECT ") + "*" + keyword(") ")
+ keyword("COMMENT ") + "'hello'";
compare(query, expected);