Skip to content

Commit

Permalink
Merge pull request #7 from mindsdb/fix-is-quoted
Browse files Browse the repository at this point in the history
Fix is quoted
  • Loading branch information
ea-rus authored Feb 4, 2025
2 parents 2a36900 + befef76 commit 239cd4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mindsdb_sql_parser/__about__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'mindsdb_sql_parser'
__package_name__ = 'mindsdb_sql_parser'
__version__ = '0.3.0'
__version__ = '0.3.1'
__description__ = "Mindsdb SQL parser"
__email__ = "[email protected]"
__author__ = 'MindsDB Inc'
Expand Down
4 changes: 3 additions & 1 deletion mindsdb_sql_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,7 @@ def json_value(self, p):
'identifier DOT star')
def identifier(self, p):
node = p[0]
is_quoted = False
if isinstance(p[2], Star):
node.parts.append(p[2])
elif isinstance(p[2], int):
Expand All @@ -1739,7 +1740,8 @@ def identifier(self, p):
node.parts.append(p[2])
else:
node.parts += p[2].parts
node.is_quoted.append(p[2].is_quoted[0])
is_quoted = p[2].is_quoted[0]
node.is_quoted.append(is_quoted)
return node

@_('quote_string',
Expand Down
5 changes: 3 additions & 2 deletions tests/test_base_sql/test_select_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,10 @@ def test_table_double_quote(self):
assert str(ast) == str(expected_ast)

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

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

# check is quoted
assert ast.targets[0].is_quoted == [True]
assert ast.targets[1].is_quoted == [True, False]
assert ast.from_table.is_quoted == [True]
assert ast.where.args[0].is_quoted == [True]

Expand Down

0 comments on commit 239cd4e

Please sign in to comment.