Skip to content

Commit 4aa5641

Browse files
authored
Merge pull request #47 from mindsdb/fix-identifier-copy
Fix identifier copy and deepcopy
2 parents 80abd53 + 9ae671d commit 4aa5641

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

mindsdb_sql_parser/ast/select/identifier.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ def __copy__(self):
9191
identifier = Identifier(parts=copy(self.parts))
9292
identifier.alias = deepcopy(self.alias)
9393
identifier.parentheses = self.parentheses
94+
identifier.is_quoted = deepcopy(self.is_quoted)
95+
identifier.is_outer = self.is_outer
96+
identifier.with_rollup = self.with_rollup
9497
if hasattr(self, 'sub_select'):
9598
identifier.sub_select = deepcopy(self.sub_select)
9699
return identifier
@@ -99,6 +102,9 @@ def __deepcopy__(self, memo):
99102
identifier = Identifier(parts=copy(self.parts))
100103
identifier.alias = deepcopy(self.alias)
101104
identifier.parentheses = self.parentheses
105+
identifier.is_quoted = deepcopy(self.is_quoted)
106+
identifier.is_outer = self.is_outer
107+
identifier.with_rollup = self.with_rollup
102108
if hasattr(self, 'sub_select'):
103109
identifier.sub_select = deepcopy(self.sub_select)
104110
return identifier

tests/test_base_sql/test_ast.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from copy import deepcopy
2+
13
from mindsdb_sql_parser.ast import *
24

35

@@ -24,3 +26,8 @@ def test_copy(self):
2426
# change
2527
ast.where.args[0] = Constant(1)
2628
assert ast.to_tree() != ast2.to_tree()
29+
30+
def test_identifier_deepcopy_is_quoted(self):
31+
ident = Identifier('`a`')
32+
ident2 = deepcopy(ident)
33+
assert ident2.is_quoted == [True]

0 commit comments

Comments
 (0)