summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdbpp/sqlParse.ll5
-rw-r--r--libdbpp/unittests/stringParse.sql1
-rw-r--r--libdbpp/unittests/testConnection.cpp4
3 files changed, 10 insertions, 0 deletions
diff --git a/libdbpp/sqlParse.ll b/libdbpp/sqlParse.ll
index 7649445..0661abc 100644
--- a/libdbpp/sqlParse.ll
+++ b/libdbpp/sqlParse.ll
@@ -24,6 +24,7 @@ term ;
any ({other}|{space})
quote '
quote_apos ''
+quote_esc \\.
dolq_start [A-Za-z\200-\377_]
dolq_cont [A-Za-z\200-\377_0-9]
dollarquote \$({dolq_start}{dolq_cont}*)?\$
@@ -92,6 +93,10 @@ scriptdir "$SCRIPTDIR"
statement += YYText();
}
+<QUOTE>{quote_esc} {
+ statement += YYText();
+}
+
<DOLLARQUOTE>{any} {
statement += YYText();
}
diff --git a/libdbpp/unittests/stringParse.sql b/libdbpp/unittests/stringParse.sql
index e764da9..736400b 100644
--- a/libdbpp/unittests/stringParse.sql
+++ b/libdbpp/unittests/stringParse.sql
@@ -1 +1,2 @@
INSERT INTO dollarQuotes(a) VALUES('apos''trophe');
+INSERT INTO name(t, i) VALUES('fancy string '' \' \r \n', 7);
diff --git a/libdbpp/unittests/testConnection.cpp b/libdbpp/unittests/testConnection.cpp
index b9cabdf..86ca2a8 100644
--- a/libdbpp/unittests/testConnection.cpp
+++ b/libdbpp/unittests/testConnection.cpp
@@ -82,6 +82,8 @@ BOOST_AUTO_TEST_CASE( parse )
BOOST_AUTO_TEST_CASE( parse2 )
{
auto mock = DB::ConnectionPtr(DB::ConnectionFactory::createNew("MockDb", "doesn't matter"));
+ auto mockdb = boost::dynamic_pointer_cast<MockDb>(mock);
+ BOOST_REQUIRE(mockdb);
std::fstream s;
s.open((rootDir / "dollarQuote.sql").string());
@@ -95,6 +97,8 @@ BOOST_AUTO_TEST_CASE( parse2 )
s.open((rootDir / "stringParse.sql").string());
mock->executeScript(s, rootDir);
s.close();
+ BOOST_REQUIRE_EQUAL(4, mockdb->executed.size());
+ BOOST_REQUIRE_EQUAL("INSERT INTO name(t, i) VALUES('fancy string '' \\' \\r \\n', 7)", mockdb->executed[3]);
BOOST_REQUIRE_THROW({
s.open((rootDir / "unterminatedComment.sql").string());