Fix previous commit changes

This commit is contained in:
kssenii 2022-11-08 14:44:45 +01:00
parent 85e448f048
commit 41852d667f
3 changed files with 29 additions and 8 deletions

View File

@ -36,9 +36,31 @@ String SettingChange::getValueString() const
return convertFieldToString(field_value);
}
void SettingChange::throwIfASTValue() const
const Field & SettingChange::getFieldValue() const
{
if (getASTValue() != nullptr)
throwIfASTValueNotConvertedToField();
return field_value;
}
Field & SettingChange::getFieldValue()
{
throwIfASTValueNotConvertedToField();
return field_value;
}
void SettingChange::setFieldValue(const Field & field)
{
field_value = field;
}
void SettingChange::setASTValue(const ASTPtr & ast)
{
ast_value = ast ? ast->clone() : ast;
}
void SettingChange::throwIfASTValueNotConvertedToField() const
{
if (getASTValue() != nullptr && field_value == Field{})
throw Exception(
ErrorCodes::LOGICAL_ERROR,
"AST value of the setting must be converted to Field value");

View File

@ -30,19 +30,19 @@ public:
friend bool operator !=(const SettingChange & lhs, const SettingChange & rhs) { return !(lhs == rhs); }
void throwIfASTValue() const;
void throwIfASTValueNotConvertedToField() const;
const String & getName() const { return name; }
String & getName() { return name; }
const Field & getFieldValue() const { throwIfASTValue(); return field_value; }
Field & getFieldValue() { throwIfASTValue(); return field_value; }
const Field & getFieldValue() const;
Field & getFieldValue();
const ASTPtr & getASTValue() const { return ast_value; }
ASTPtr & getASTValue() { return ast_value; }
void setFieldValue(const Field & field) { field_value = field; }
void setASTValue(const ASTPtr & ast) { ast_value = ast->clone(); }
void setFieldValue(const Field & field);
void setASTValue(const ASTPtr & ast);
String getValueString() const;
};

View File

@ -616,7 +616,6 @@ static StoragePtr create(const StorageFactory::Arguments & args)
const auto & ast_value = assert_cast<const ASTFunction &>(*change.getASTValue());
auto value = createDiskFromDiskAST(ast_value, context);
change.setFieldValue(value);
change.setASTValue(nullptr);
break;
}
}