Skip to content

Commit 93540e2

Browse files
committed
bump version
1 parent 707861f commit 93540e2

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

mindsdb_sql_parser/ast/select/identifier.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import re
22
from copy import copy, deepcopy
3+
from typing import List
34

45
from mindsdb_sql_parser.ast.base import ASTNode
56
from mindsdb_sql_parser.utils import indent
@@ -11,9 +12,13 @@
1112

1213

1314
def path_str_to_parts(path_str: str):
14-
match = re.finditer(path_str_parts_regex, path_str)
15-
parts = [x[0].strip('`') for x in match]
16-
return parts
15+
parts, is_quoted = [], []
16+
for x in re.finditer(path_str_parts_regex, path_str):
17+
part = x[0].strip('`')
18+
parts.append(part)
19+
is_quoted.append(x[0] != part)
20+
21+
return parts, is_quoted
1722

1823

1924
RESERVED_KEYWORDS = {
@@ -42,13 +47,17 @@ def __init__(self, path_str=None, parts=None, *args, **kwargs):
4247
parts = [Star()]
4348

4449
if path_str and not parts:
45-
parts = path_str_to_parts(path_str)
50+
parts, is_quoted = path_str_to_parts(path_str)
51+
else:
52+
is_quoted = [False] * len(parts)
4653
assert isinstance(parts, list)
4754
self.parts = parts
55+
# parts which were quoted
56+
self.is_quoted: List[bool] = is_quoted
4857

4958
@classmethod
5059
def from_path_str(self, value, *args, **kwargs):
51-
parts = path_str_to_parts(value)
60+
parts, _ = path_str_to_parts(value)
5261
return Identifier(parts=parts, *args, **kwargs)
5362

5463
def parts_to_str(self):

mindsdb_sql_parser/parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def from_table(self, p):
12641264
@_('PLUGINS',
12651265
'ENGINES')
12661266
def from_table(self, p):
1267-
return Identifier.from_path_str(p[0])
1267+
return Identifier(p[0])
12681268

12691269
@_('identifier')
12701270
def from_table(self, p):
@@ -1739,6 +1739,7 @@ def identifier(self, p):
17391739
node.parts.append(p[2])
17401740
else:
17411741
node.parts += p[2].parts
1742+
node.is_quoted.append(p[2].is_quoted[0])
17421743
return node
17431744

17441745
@_('quote_string',
@@ -1749,7 +1750,7 @@ def string(self, p):
17491750
@_('id', 'dquote_string')
17501751
def identifier(self, p):
17511752
value = p[0]
1752-
return Identifier.from_path_str(value)
1753+
return Identifier(value)
17531754

17541755
@_('PARAMETER')
17551756
def parameter(self, p):

0 commit comments

Comments
 (0)