2018-08-07 13:58:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Part of the ALTER UPDATE statement of the form: column = expr
|
|
|
|
class ASTAssignment : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String column_name;
|
2020-11-29 13:43:24 +00:00
|
|
|
|
|
|
|
ASTPtr expression() const
|
|
|
|
{
|
|
|
|
return children.at(0);
|
|
|
|
}
|
2018-08-07 13:58:11 +00:00
|
|
|
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char delim) const override { return "Assignment" + (delim + column_name); }
|
2018-08-07 13:58:11 +00:00
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
|
|
|
auto res = std::make_shared<ASTAssignment>(*this);
|
2020-11-29 13:43:24 +00:00
|
|
|
res->children = { expression()->clone() };
|
2018-08-07 13:58:11 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
2022-03-13 12:05:14 +00:00
|
|
|
|
2018-08-07 13:58:11 +00:00
|
|
|
settings.ostr << (settings.hilite ? hilite_identifier : "");
|
|
|
|
settings.writeIdentifier(column_name);
|
|
|
|
settings.ostr << (settings.hilite ? hilite_none : "");
|
|
|
|
|
|
|
|
settings.ostr << (settings.hilite ? hilite_operator : "") << " = " << (settings.hilite ? hilite_none : "");
|
|
|
|
|
2020-11-29 13:43:24 +00:00
|
|
|
expression()->formatImpl(settings, state, frame);
|
2018-08-07 13:58:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|