Skip to content

Commit 239cd4e

Browse files
authored
Merge pull request #7 from mindsdb/fix-is-quoted
Fix is quoted
2 parents 2a36900 + befef76 commit 239cd4e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

mindsdb_sql_parser/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'mindsdb_sql_parser'
22
__package_name__ = 'mindsdb_sql_parser'
3-
__version__ = '0.3.0'
3+
__version__ = '0.3.1'
44
__description__ = "Mindsdb SQL parser"
55
__email__ = "[email protected]"
66
__author__ = 'MindsDB Inc'

mindsdb_sql_parser/parser.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,7 @@ def json_value(self, p):
17311731
'identifier DOT star')
17321732
def identifier(self, p):
17331733
node = p[0]
1734+
is_quoted = False
17341735
if isinstance(p[2], Star):
17351736
node.parts.append(p[2])
17361737
elif isinstance(p[2], int):
@@ -1739,7 +1740,8 @@ def identifier(self, p):
17391740
node.parts.append(p[2])
17401741
else:
17411742
node.parts += p[2].parts
1742-
node.is_quoted.append(p[2].is_quoted[0])
1743+
is_quoted = p[2].is_quoted[0]
1744+
node.is_quoted.append(is_quoted)
17431745
return node
17441746

17451747
@_('quote_string',

tests/test_base_sql/test_select_structure.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1183,10 +1183,10 @@ def test_table_double_quote(self):
11831183
assert str(ast) == str(expected_ast)
11841184

11851185
def test_double_quote_render_skip(self):
1186-
sql = 'select `KEY_ID` from `Table1` where `id`=2'
1186+
sql = 'select `KEY_ID`, `a`.* from `Table1` where `id`=2'
11871187

11881188
expected_ast = Select(
1189-
targets=[Identifier('KEY_ID')],
1189+
targets=[Identifier('KEY_ID'), Identifier(parts=['a', Star()])],
11901190
from_table=Identifier(parts=['Table1']),
11911191
where=BinaryOperation(op='=', args=[
11921192
Identifier('id'), Constant(2)
@@ -1198,6 +1198,7 @@ def test_double_quote_render_skip(self):
11981198

11991199
# check is quoted
12001200
assert ast.targets[0].is_quoted == [True]
1201+
assert ast.targets[1].is_quoted == [True, False]
12011202
assert ast.from_table.is_quoted == [True]
12021203
assert ast.where.args[0].is_quoted == [True]
12031204

0 commit comments

Comments
 (0)