mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 11:22:12 +00:00
30 lines
585 B
C++
30 lines
585 B
C++
#include <Backups/SettingsFieldOptionalString.h>
|
|
#include <Common/ErrorCodes.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int CANNOT_PARSE_BACKUP_SETTINGS;
|
|
}
|
|
|
|
SettingFieldOptionalString::SettingFieldOptionalString(const Field & field)
|
|
{
|
|
if (field.getType() == Field::Types::Null)
|
|
{
|
|
value = std::nullopt;
|
|
return;
|
|
}
|
|
|
|
if (field.getType() == Field::Types::String)
|
|
{
|
|
value = field.get<const String &>();
|
|
return;
|
|
}
|
|
|
|
throw Exception(ErrorCodes::CANNOT_PARSE_BACKUP_SETTINGS, "Cannot get string from {}", field);
|
|
}
|
|
|
|
}
|