Skip to content

Commit

Permalink
Minor modifications
Browse files Browse the repository at this point in the history
* Updated test case names to be more self-evident
* Added exmplanatory comment to replaceEscapeSequences().
  • Loading branch information
Enmk committed Apr 14, 2020
1 parent 4ed271e commit 4b0f0ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions driver/escaping/escape_sequences.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

#include <string>

/** Replaces ODBC escape-sequence into a ClickHouse SQL-dialect.
*
* In case of error, input is returned as-is, with no modifications.
*/
std::string replaceEscapeSequences(const std::string & query);
12 changes: 6 additions & 6 deletions driver/test/escape_sequences_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ TEST(EscapeSequencesCase, ParseIdent7) {
"SELECT SUM(toInt64(`0 a b $ c`.abc.`0 a b $ c`))");
}

TEST(EscapeSequencesCase, ParseIdentX1) {
TEST(EscapeSequencesCase, ParseIdent_Negative1) {
ASSERT_EQ(replaceEscapeSequences("SELECT SUM({fn CONVERT(0 a b $ c, SQL_BIGINT)})"),
"SELECT SUM({fn CONVERT(0 a b $ c, SQL_BIGINT)})");
}

TEST(EscapeSequencesCase, ParseIdentX2) {
TEST(EscapeSequencesCase, ParseIdent_Negative2) {
ASSERT_EQ(replaceEscapeSequences("SELECT SUM({fn CONVERT(.abc, SQL_BIGINT)})"),
"SELECT SUM({fn CONVERT(.abc, SQL_BIGINT)})");
}

TEST(EscapeSequencesCase, ParseIdentX3) {
TEST(EscapeSequencesCase, ParseIdent_Negative3) {
ASSERT_EQ(replaceEscapeSequences("SELECT SUM({fn CONVERT(.`abc`, SQL_BIGINT)})"),
"SELECT SUM({fn CONVERT(.`abc`, SQL_BIGINT)})");
}

TEST(EscapeSequencesCase, ParseIdentX4) {
TEST(EscapeSequencesCase, ParseIdent_Negative4) {
ASSERT_EQ(replaceEscapeSequences("SELECT SUM({fn CONVERT(abc., SQL_BIGINT)})"),
"SELECT SUM({fn CONVERT(abc., SQL_BIGINT)})");
}

TEST(EscapeSequencesCase, ParseIdentX5) {
TEST(EscapeSequencesCase, ParseIdent_Negative5) {
ASSERT_EQ(replaceEscapeSequences("SELECT SUM({fn CONVERT(`abc`., SQL_BIGINT)})"),
"SELECT SUM({fn CONVERT(`abc`., SQL_BIGINT)})");
}

TEST(EscapeSequencesCase, ParseIdentX6) {
TEST(EscapeSequencesCase, ParseIdent_Negative6) {
ASSERT_EQ(replaceEscapeSequences("SELECT SUM({fn CONVERT(abc..abc, SQL_BIGINT)})"),
"SELECT SUM({fn CONVERT(abc..abc, SQL_BIGINT)})");
}
Expand Down

0 comments on commit 4b0f0ff

Please sign in to comment.