diff --git a/mindsdb_sql_parser/lexer.py b/mindsdb_sql_parser/lexer.py index 7a76fe0..4a7b370 100644 --- a/mindsdb_sql_parser/lexer.py +++ b/mindsdb_sql_parser/lexer.py @@ -346,12 +346,10 @@ def INTEGER(self, t): @_(r"'(?:\\.|[^'])*(?:''(?:\\.|[^'])*)*'") def QUOTE_STRING(self, t): - t.value = t.value.replace('\\"', '"').replace("\\'", "'").replace("''", "'") return t @_(r'"(?:\\.|[^"])*"') def DQUOTE_STRING(self, t): - t.value = t.value.replace('\\"', '"').replace("\\'", "'") return t @_(r'\n+') diff --git a/mindsdb_sql_parser/parser.py b/mindsdb_sql_parser/parser.py index 5980296..6403265 100644 --- a/mindsdb_sql_parser/parser.py +++ b/mindsdb_sql_parser/parser.py @@ -2006,11 +2006,11 @@ def integer(self, p): @_('QUOTE_STRING') def quote_string(self, p): - return p[0].strip('\'') + return p[0].replace('\\"', '"').replace("\\'", "'").replace("''", "'").strip('\'') @_('DQUOTE_STRING') def dquote_string(self, p): - return p[0].strip('\"') + return p[0].replace('\\"', '"').replace("\\'", "'").strip('\"') # for raw query diff --git a/tests/test_mindsdb/test_selects.py b/tests/test_mindsdb/test_selects.py index 2c6ee71..c43f104 100644 --- a/tests/test_mindsdb/test_selects.py +++ b/tests/test_mindsdb/test_selects.py @@ -45,7 +45,7 @@ def test_select_status_column(self): def test_native_query(self): sql = """ SELECT status - FROM int1 (select q from p from r) + FROM int1 (select q from p from r where x = 'test''test') group by 1 limit 1 """ @@ -54,7 +54,7 @@ def test_native_query(self): targets=[Identifier('status')], from_table=NativeQuery( integration=Identifier('int1'), - query='select q from p from r' + query="select q from p from r where x = 'test''test'" ), limit=Constant(1), group_by=[Constant(1)]