mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Simplier string get
This commit is contained in:
parent
c4553f2f7b
commit
5818dfeb45
@ -33,17 +33,11 @@ namespace
|
||||
using NamesToTypeNames = std::unordered_map<std::string, std::string>;
|
||||
/// Get value from field and convert it to string.
|
||||
/// Also remove quotes from strings.
|
||||
String getUnquotedFieldString(const Field & field)
|
||||
String getFieldAsString(const Field & field)
|
||||
{
|
||||
String string = applyVisitor(FieldVisitorToString(), field);
|
||||
if (string.front() == '\'')
|
||||
{
|
||||
String result;
|
||||
ReadBufferFromString buf(string);
|
||||
readQuotedString(result, buf);
|
||||
return result;
|
||||
}
|
||||
return string;
|
||||
if (field.getType() == Field::Types::Which::String)
|
||||
return field.get<String>();
|
||||
return applyVisitor(FieldVisitorToString(), field);
|
||||
}
|
||||
|
||||
|
||||
@ -190,7 +184,7 @@ void buildSingleAttribute(
|
||||
AutoPtr<Element> null_value_element(doc->createElement("null_value"));
|
||||
String null_value_str;
|
||||
if (dict_attr->default_value)
|
||||
null_value_str = getUnquotedFieldString(dict_attr->default_value->as<ASTLiteral>()->value);
|
||||
null_value_str = getFieldAsString(dict_attr->default_value->as<ASTLiteral>()->value);
|
||||
AutoPtr<Text> null_value(doc->createTextNode(null_value_str));
|
||||
null_value_element->appendChild(null_value);
|
||||
attribute_element->appendChild(null_value_element);
|
||||
@ -204,7 +198,7 @@ void buildSingleAttribute(
|
||||
if (const auto * literal = dict_attr->expression->as<ASTLiteral>();
|
||||
literal && literal->value.getType() == Field::Types::String)
|
||||
{
|
||||
expression_str = getUnquotedFieldString(literal->value);
|
||||
expression_str = getFieldAsString(literal->value);
|
||||
}
|
||||
else
|
||||
expression_str = queryToString(dict_attr->expression);
|
||||
@ -353,7 +347,7 @@ void buildConfigurationFromFunctionWithKeyValueArguments(
|
||||
}
|
||||
else if (auto literal = pair->second->as<const ASTLiteral>(); literal)
|
||||
{
|
||||
AutoPtr<Text> value(doc->createTextNode(getUnquotedFieldString(literal->value)));
|
||||
AutoPtr<Text> value(doc->createTextNode(getFieldAsString(literal->value)));
|
||||
current_xml_element->appendChild(value);
|
||||
}
|
||||
else if (auto list = pair->second->as<const ASTExpressionList>(); list)
|
||||
|
Loading…
Reference in New Issue
Block a user