Skip to content

Commit 5a2b0ea

Browse files
committed
simplify formatting of astauth
1 parent cc13783 commit 5a2b0ea

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/Parsers/Access/ASTAuthenticationData.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@ void ASTAuthenticationData::formatImpl(const FormatSettings & settings, FormatSt
160160
auth_type_name = AuthenticationTypeInfo::get(*type).name;
161161
}
162162

163-
const char * identified_string = settings.additional_authentication_method ? " ADD IDENTIFIED" : " IDENTIFIED";
164-
165-
settings.ostr << (settings.hilite ? IAST::hilite_keyword : "") << identified_string << (settings.hilite ? IAST::hilite_none : "");
163+
settings.ostr << (settings.hilite ? IAST::hilite_keyword : "") << " IDENTIFIED" << (settings.hilite ? IAST::hilite_none : "");
166164

167165
if (!auth_type_name.empty())
168166
{

src/Parsers/Access/ASTCreateUserQuery.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ namespace
2121

2222
void formatAuthenticationData(const std::vector<std::shared_ptr<ASTAuthenticationData>> & authentication_methods, const IAST::FormatSettings & settings)
2323
{
24+
/*
25+
* The first authentication method must be formatted in the form of: `IDENTIFIED WITH xyz..`
26+
* The remaining ones shall contain the `ADD`: `ADD IDENTIFIED WITH`.
27+
* */
2428
authentication_methods[0]->format(settings);
2529

26-
auto settings_with_additional_authentication_method = settings;
27-
settings_with_additional_authentication_method.additional_authentication_method = true;
28-
29-
for (auto i = 1u; i < authentication_methods.size(); i++)
30+
for (std::size_t i = 1; i < authentication_methods.size(); i++)
3031
{
31-
authentication_methods[i]->format(settings_with_additional_authentication_method);
32+
settings.ostr << (settings.hilite ? IAST::hilite_keyword : "") << " ADD" << (settings.hilite ? IAST::hilite_none : "");
33+
authentication_methods[i]->format(settings);
3234
}
3335
}
3436

src/Parsers/IAST.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class IAST : public std::enable_shared_from_this<IAST>, public TypePromotion<IAS
201201
bool show_secrets; /// Show secret parts of the AST (e.g. passwords, encryption keys).
202202
char nl_or_ws; /// Newline or whitespace.
203203
LiteralEscapingStyle literal_escaping_style;
204-
bool additional_authentication_method;
205204

206205
explicit FormatSettings(
207206
WriteBuffer & ostr_,
@@ -210,8 +209,7 @@ class IAST : public std::enable_shared_from_this<IAST>, public TypePromotion<IAS
210209
bool always_quote_identifiers_ = false,
211210
IdentifierQuotingStyle identifier_quoting_style_ = IdentifierQuotingStyle::Backticks,
212211
bool show_secrets_ = true,
213-
LiteralEscapingStyle literal_escaping_style_ = LiteralEscapingStyle::Regular,
214-
bool additional_authentication_method_ = false)
212+
LiteralEscapingStyle literal_escaping_style_ = LiteralEscapingStyle::Regular)
215213
: ostr(ostr_)
216214
, one_line(one_line_)
217215
, hilite(hilite_)
@@ -220,7 +218,6 @@ class IAST : public std::enable_shared_from_this<IAST>, public TypePromotion<IAS
220218
, show_secrets(show_secrets_)
221219
, nl_or_ws(one_line ? ' ' : '\n')
222220
, literal_escaping_style(literal_escaping_style_)
223-
, additional_authentication_method(additional_authentication_method_)
224221
{
225222
}
226223

@@ -233,7 +230,6 @@ class IAST : public std::enable_shared_from_this<IAST>, public TypePromotion<IAS
233230
, show_secrets(other.show_secrets)
234231
, nl_or_ws(other.nl_or_ws)
235232
, literal_escaping_style(other.literal_escaping_style)
236-
, additional_authentication_method(other.additional_authentication_method)
237233
{
238234
}
239235

0 commit comments

Comments
 (0)