mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Make sure parens are always matching
This commit is contained in:
parent
567270afa8
commit
a1fb0ad706
@ -70,8 +70,14 @@ ASTPtr ASTAlterCommand::clone() const
|
|||||||
|
|
||||||
void ASTAlterCommand::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
void ASTAlterCommand::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||||
{
|
{
|
||||||
|
scope_guard closing_bracket_guard;
|
||||||
if (format_alter_commands_with_parentheses)
|
if (format_alter_commands_with_parentheses)
|
||||||
|
{
|
||||||
settings.ostr << "(";
|
settings.ostr << "(";
|
||||||
|
closing_bracket_guard = make_scope_guard([&settings](){
|
||||||
|
settings.ostr << ")";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (type == ASTAlterCommand::ADD_COLUMN)
|
if (type == ASTAlterCommand::ADD_COLUMN)
|
||||||
{
|
{
|
||||||
@ -498,9 +504,6 @@ void ASTAlterCommand::formatImpl(const FormatSettings & settings, FormatState &
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw Exception(ErrorCodes::UNEXPECTED_AST_STRUCTURE, "Unexpected type of ALTER");
|
throw Exception(ErrorCodes::UNEXPECTED_AST_STRUCTURE, "Unexpected type of ALTER");
|
||||||
|
|
||||||
if (format_alter_commands_with_parentheses)
|
|
||||||
settings.ostr << ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTAlterCommand::forEachPointerToChild(std::function<void(void**)> f)
|
void ASTAlterCommand::forEachPointerToChild(std::function<void(void**)> f)
|
||||||
|
@ -43,3 +43,10 @@ ALTER TABLE a\\n (DROP COLUMN b),\\n (DROP COLUMN c)
|
|||||||
"""
|
"""
|
||||||
result = node.query(INPUT)
|
result = node.query(INPUT)
|
||||||
assert result == EXPECTED_OUTPUT
|
assert result == EXPECTED_OUTPUT
|
||||||
|
|
||||||
|
|
||||||
|
def test_move_partition_to_table_command():
|
||||||
|
INPUT = "SELECT formatQuery('ALTER TABLE a MOVE PARTITION tuple() TO TABLE b')"
|
||||||
|
EXPECTED_OUTPUT = "ALTER TABLE a\\n (MOVE PARTITION tuple() TO TABLE b)"
|
||||||
|
result = node.query(INPUT)
|
||||||
|
assert result == EXPECTED_OUTPUT
|
||||||
|
Loading…
Reference in New Issue
Block a user