1#include <Parsers/ASTDictionaryAttributeDeclaration.h>
2#include <Common/quoteString.h>
3
4
5namespace DB
6{
7ASTPtr ASTDictionaryAttributeDeclaration::clone() const
8{
9 const auto res = std::make_shared<ASTDictionaryAttributeDeclaration>(*this);
10 res->children.clear();
11
12 if (type)
13 {
14 res->type = type->clone();
15 res->children.push_back(res->type);
16 }
17
18 if (default_value)
19 {
20 res->default_value = default_value;
21 res->children.push_back(res->default_value);
22 }
23
24 if (expression)
25 {
26 res->expression = expression->clone();
27 res->children.push_back(res->expression);
28 }
29
30 return res;
31}
32
33void ASTDictionaryAttributeDeclaration::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
34{
35 frame.need_parens = false;
36
37 if (!settings.one_line)
38 settings.ostr << settings.nl_or_ws << std::string(4 * frame.indent, ' ');
39
40 settings.ostr << backQuote(name);
41
42 if (type)
43 {
44 settings.ostr << ' ';
45 type->formatImpl(settings, state, frame);
46 }
47
48 if (default_value)
49 {
50 settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "DEFAULT" << (settings.hilite ? hilite_none : "") << ' ';
51 default_value->formatImpl(settings, state, frame);
52 }
53
54 if (expression)
55 {
56 settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "EXPRESSION" << (settings.hilite ? hilite_none : "") << ' ';
57 expression->formatImpl(settings, state, frame);
58 }
59
60 if (hierarchical)
61 settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "HIERARCHICAL";
62
63 if (injective)
64 settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "INJECTIVE";
65
66 if (is_object_id)
67 settings.ostr << ' ' << (settings.hilite ? hilite_keyword : "") << "IS_OBJECT_ID";
68}
69
70}
71