Reverted constructor change

This commit is contained in:
Kostiantyn Storozhuk 2021-06-29 14:37:53 +08:00
parent c2c78929cb
commit 296593716d
4 changed files with 15 additions and 9 deletions

View File

@ -102,8 +102,7 @@ std::map<String, ColumnsDescription> fetchTablesColumnsList(
for (size_t i = 0; i < rows; ++i) for (size_t i = 0; i < rows; ++i)
{ {
String table_name = table_name_col[i].safeGet<String>(); String table_name = table_name_col[i].safeGet<String>();
tables_and_columns[table_name].add( ColumnDescription column_description(
ColumnDescription(
column_name_col[i].safeGet<String>(), column_name_col[i].safeGet<String>(),
convertMySQLDataType( convertMySQLDataType(
type_support, type_support,
@ -112,8 +111,11 @@ std::map<String, ColumnsDescription> fetchTablesColumnsList(
is_unsigned_col[i].safeGet<UInt64>(), is_unsigned_col[i].safeGet<UInt64>(),
char_max_length_col[i].safeGet<UInt64>(), char_max_length_col[i].safeGet<UInt64>(),
precision_col[i].safeGet<UInt64>(), precision_col[i].safeGet<UInt64>(),
scale_col[i].safeGet<UInt64>()), scale_col[i].safeGet<UInt64>())
column_comment_col[i].safeGet<String>())); );
column_description.comment = column_comment_col[i].safeGet<String>();
tables_and_columns[table_name].add(column_description);
} }
} }
return tables_and_columns; return tables_and_columns;

View File

@ -137,8 +137,12 @@ static ColumnsDescription createColumnsDescription(const NamesAndTypesList & col
if (const auto * options = declare_column->column_options->as<MySQLParser::ASTDeclareOptions>()) if (const auto * options = declare_column->column_options->as<MySQLParser::ASTDeclareOptions>())
if (options->changes.count("comment")) if (options->changes.count("comment"))
comment = options->changes.at("comment")->as<ASTLiteral>()->value.safeGet<String>(); comment = options->changes.at("comment")->as<ASTLiteral>()->value.safeGet<String>();
columns_description.add(ColumnDescription(column_name_and_type->name, column_name_and_type->type, comment)); ColumnDescription column_description(column_name_and_type->name, column_name_and_type->type);
if(!comment.empty())
column_description.comment = std::move(comment);
columns_description.add(column_description);
} }
return columns_description; return columns_description;

View File

@ -43,8 +43,8 @@ namespace ErrorCodes
extern const int LOGICAL_ERROR; extern const int LOGICAL_ERROR;
} }
ColumnDescription::ColumnDescription(String name_, DataTypePtr type_, String comment_) ColumnDescription::ColumnDescription(String name_, DataTypePtr type_)
: name(std::move(name_)), type(std::move(type_)), comment(std::move(comment_)) : name(std::move(name_)), type(std::move(type_))
{ {
} }

View File

@ -39,7 +39,7 @@ struct ColumnDescription
ColumnDescription() = default; ColumnDescription() = default;
ColumnDescription(ColumnDescription &&) = default; ColumnDescription(ColumnDescription &&) = default;
ColumnDescription(const ColumnDescription &) = default; ColumnDescription(const ColumnDescription &) = default;
ColumnDescription(String name_, DataTypePtr type_, String comment_ = ""); ColumnDescription(String name_, DataTypePtr type_);
bool operator==(const ColumnDescription & other) const; bool operator==(const ColumnDescription & other) const;
bool operator!=(const ColumnDescription & other) const { return !(*this == other); } bool operator!=(const ColumnDescription & other) const { return !(*this == other); }