Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clickhouse/types/type_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ TypeParser::Token TypeParser::NextToken() {
scratch_ += '\'';
++cur_;
}
else if ('\'' == *cur_ && end_ - cur_ > 1 && *(cur_ + 1) == '\'') {
// doubled quote is an escaped single quote
scratch_ += '\'';
++cur_;
}
else if ('\'' == *cur_) {
scratch_ += *(cur_++);
return Token{Token::QuotedString, StringView(scratch_)};
Expand Down
13 changes: 13 additions & 0 deletions ut/type_parser_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,19 @@ TEST(TypeParserCase, ParseTimezoneEscapedStrings) {
}
}

TEST(TypeParserCase, ParseEnum_DoubledSingleQuote) {
TypeAst ast;
ASSERT_TRUE(TypeParser("Enum8('it''s' = 1, 'b' = 2)").Parse(&ast));
ASSERT_EQ(ast.meta, TypeAst::Enum);
ASSERT_EQ(ast.elements.size(), 4u);
EXPECT_EQ(ast.elements[0].value_string, "it's");
EXPECT_EQ(ast.elements[2].value_string, "b");

TypeAst edge;
ASSERT_TRUE(TypeParser("Enum8('''a''' = 1)").Parse(&edge));
EXPECT_EQ(edge.elements[0].value_string, "'a'");
}

TEST(TypeParserCase, ParseTimezone_AllEscapedBytes) {
// {fragment as seen by the parser, expected decoded raw byte}
const std::vector<std::pair<std::string, char>> cases = {
Expand Down
Loading