|
1 | 1 | import re |
2 | 2 | from copy import copy, deepcopy |
| 3 | +from typing import List |
3 | 4 |
|
4 | 5 | from mindsdb_sql_parser.ast.base import ASTNode |
5 | 6 | from mindsdb_sql_parser.utils import indent |
|
11 | 12 |
|
12 | 13 |
|
13 | 14 | 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 |
17 | 22 |
|
18 | 23 |
|
19 | 24 | RESERVED_KEYWORDS = { |
@@ -42,13 +47,17 @@ def __init__(self, path_str=None, parts=None, *args, **kwargs): |
42 | 47 | parts = [Star()] |
43 | 48 |
|
44 | 49 | 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) |
46 | 53 | assert isinstance(parts, list) |
47 | 54 | self.parts = parts |
| 55 | + # parts which were quoted |
| 56 | + self.is_quoted: List[bool] = is_quoted |
48 | 57 |
|
49 | 58 | @classmethod |
50 | 59 | def from_path_str(self, value, *args, **kwargs): |
51 | | - parts = path_str_to_parts(value) |
| 60 | + parts, _ = path_str_to_parts(value) |
52 | 61 | return Identifier(parts=parts, *args, **kwargs) |
53 | 62 |
|
54 | 63 | def parts_to_str(self): |
|
0 commit comments