From ba4613afe304d17bbf67506954e61ab6bd745250 Mon Sep 17 00:00:00 2001 From: Elkin Andrew Date: Fri, 20 Sep 2024 12:43:00 +0300 Subject: [PATCH] support doublequoted table name --- mindsdb_sql/parser/dialects/mindsdb/parser.py | 10 +++++----- .../test_parser/test_base_sql/test_select_structure.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mindsdb_sql/parser/dialects/mindsdb/parser.py b/mindsdb_sql/parser/dialects/mindsdb/parser.py index 9e73355..b91dd87 100644 --- a/mindsdb_sql/parser/dialects/mindsdb/parser.py +++ b/mindsdb_sql/parser/dialects/mindsdb/parser.py @@ -1691,16 +1691,16 @@ def identifier(self, p): node.parts += p[2].parts return node - @_('id') - def identifier(self, p): - value = p[0] - return Identifier.from_path_str(value) - @_('quote_string', 'dquote_string') def string(self, p): return p[0] + @_('id', 'dquote_string') + def identifier(self, p): + value = p[0] + return Identifier.from_path_str(value) + @_('PARAMETER') def parameter(self, p): return Parameter(value=p.PARAMETER) diff --git a/tests/test_parser/test_base_sql/test_select_structure.py b/tests/test_parser/test_base_sql/test_select_structure.py index 8f9df64..c9153e0 100644 --- a/tests/test_parser/test_base_sql/test_select_structure.py +++ b/tests/test_parser/test_base_sql/test_select_structure.py @@ -1124,3 +1124,13 @@ def test_alternative_casting(self): ast = parse_sql(sql) assert str(ast) == str(expected_ast) + def test_table_double_quote(self): + expected_ast = Select( + targets=[Identifier('account_id')], + from_table=Identifier(parts=['order']) + ) + + sql = 'select account_id from "order"' + + ast = parse_sql(sql) + assert str(ast) == str(expected_ast)