improve test and simplify code

This commit is contained in:
FArthur-cmd 2022-10-08 11:07:46 +00:00
parent e07a3e1193
commit 2bef2b09de
5 changed files with 7 additions and 6 deletions

View File

@ -118,9 +118,7 @@ bool SettingsConstraints::checkImpl(const Settings & current_settings, SettingCh
bool cannot_cast;
auto cast_value = [&](const Field & x) -> Field
{
/// `Default` can't be cast to other types, so it should be checked separately
String setting_value;
if (x.tryGet(setting_value) && setting_value == "DEFAULT")
if (x.isNull())
return {};
cannot_cast = false;
if (reaction == THROW_ON_VIOLATION)

View File

@ -148,8 +148,7 @@ std::vector<String> Settings::getAllRegisteredNames() const
void Settings::set(std::string_view name, const Field & value)
{
String setting_value;
if (value.tryGet(setting_value) && setting_value == "DEFAULT") {
if (value.isNull()) {
resetToDefault(name);
} else {
BaseSettings::set(name, value);

View File

@ -110,7 +110,7 @@ bool ParserSetQuery::parseNameValuePair(SettingChange & change, IParser::Pos & p
else if (ParserKeyword("FALSE").ignore(pos, expected))
value = std::make_shared<ASTLiteral>(Field(static_cast<UInt64>(0)));
else if (ParserKeyword("DEFAULT").ignore(pos, expected))
value = std::make_shared<ASTLiteral>(Field("DEFAULT"));
value = std::make_shared<ASTLiteral>(Field());
else if (!value_p.parse(pos, value, expected))
return false;

View File

@ -1,3 +1,5 @@
1048545
100000
1
1048545
0

View File

@ -3,5 +3,7 @@
SELECT value FROM system.settings where name='max_insert_block_size';
SET max_insert_block_size=100000;
SELECT value FROM system.settings where name='max_insert_block_size';
SELECT changed FROM system.settings where name='max_insert_block_size';
SET max_insert_block_size=DEFAULT;
SELECT value FROM system.settings where name='max_insert_block_size';
SELECT changed FROM system.settings where name='max_insert_block_size';