Checking updatable for user settings

This commit is contained in:
alesapin 2019-08-07 19:13:28 +03:00
parent 7409f1a3de
commit 75c3ed967a
3 changed files with 16 additions and 2 deletions

View File

@ -1126,6 +1126,17 @@ void Context::applySettingsChanges(const SettingsChanges & changes)
applySettingChange(change); applySettingChange(change);
} }
void Context::updateSettingsChanges(const SettingsChanges & changes)
{
auto lock = getLock();
for (const SettingChange & change : changes)
{
if (change.name == "profile")
setProfile(change.value.safeGet<String>());
else
settings.updateFromChange(change);
}
}
void Context::checkSettingsConstraints(const SettingChange & change) void Context::checkSettingsConstraints(const SettingChange & change)
{ {

View File

@ -281,6 +281,9 @@ public:
void applySettingChange(const SettingChange & change); void applySettingChange(const SettingChange & change);
void applySettingsChanges(const SettingsChanges & changes); void applySettingsChanges(const SettingsChanges & changes);
/// Update checking that each setting is updatable
void updateSettingsChanges(const SettingsChanges & changes);
/// Checks the constraints. /// Checks the constraints.
void checkSettingsConstraints(const SettingChange & change); void checkSettingsConstraints(const SettingChange & change);
void checkSettingsConstraints(const SettingsChanges & changes); void checkSettingsConstraints(const SettingsChanges & changes);

View File

@ -10,7 +10,7 @@ BlockIO InterpreterSetQuery::execute()
{ {
const auto & ast = query_ptr->as<ASTSetQuery &>(); const auto & ast = query_ptr->as<ASTSetQuery &>();
context.checkSettingsConstraints(ast.changes); context.checkSettingsConstraints(ast.changes);
context.getSessionContext().applySettingsChanges(ast.changes); context.getSessionContext().updateSettingsChanges(ast.changes);
return {}; return {};
} }
@ -19,7 +19,7 @@ void InterpreterSetQuery::executeForCurrentContext()
{ {
const auto & ast = query_ptr->as<ASTSetQuery &>(); const auto & ast = query_ptr->as<ASTSetQuery &>();
context.checkSettingsConstraints(ast.changes); context.checkSettingsConstraints(ast.changes);
context.applySettingsChanges(ast.changes); context.updateSettingsChanges(ast.changes);
} }
} }