1#pragma once
2
3#include <Parsers/IAST.h>
4
5namespace DB
6{
7
8/// Part of the ALTER UPDATE statement of the form: column = expr
9class ASTAssignment : public IAST
10{
11public:
12 String column_name;
13 ASTPtr expression;
14
15 String getID(char delim) const override { return "Assignment" + (delim + column_name); }
16
17 ASTPtr clone() const override
18 {
19 auto res = std::make_shared<ASTAssignment>(*this);
20 res->children.clear();
21
22 if (expression)
23 {
24 res->expression = expression->clone();
25 res->children.push_back(res->expression);
26 }
27
28 return res;
29 }
30
31protected:
32 void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
33 {
34 settings.ostr << (settings.hilite ? hilite_identifier : "");
35 settings.writeIdentifier(column_name);
36 settings.ostr << (settings.hilite ? hilite_none : "");
37
38 settings.ostr << (settings.hilite ? hilite_operator : "") << " = " << (settings.hilite ? hilite_none : "");
39
40 expression->formatImpl(settings, state, frame);
41 }
42};
43
44}
45