@@ -45,7 +45,10 @@ def get_reserved_words() -> set[str]:
4545
4646
4747class Identifier (ASTNode ):
48- def __init__ (self , path_str = None , parts = None , is_outer = False , with_rollup = False , * args , ** kwargs ):
48+ def __init__ (
49+ self , path_str = None , parts = None , is_outer = False , with_rollup = False ,
50+ is_quoted : list [bool ] | None = None , * args , ** kwargs
51+ ):
4952 super ().__init__ (* args , ** kwargs )
5053 assert path_str or parts , "Either path_str or parts must be provided for an Identifier"
5154 assert not (path_str and parts ), "Provide either path_str or parts, but not both"
@@ -54,7 +57,7 @@ def __init__(self, path_str=None, parts=None, is_outer=False, with_rollup=False,
5457
5558 if path_str and not parts :
5659 parts , is_quoted = path_str_to_parts (path_str )
57- else :
60+ elif is_quoted is None :
5861 is_quoted = [False ] * len (parts )
5962 assert isinstance (parts , list )
6063 self .parts = parts
@@ -73,8 +76,7 @@ def append(self, other: "Identifier") -> None:
7376 self .parts += other .parts
7477 self .is_quoted += other .is_quoted
7578
76- def parts_to_str (self ):
77- out_parts = []
79+ def iter_parts_str (self ):
7880 reserved_words = get_reserved_words ()
7981 for part , is_quoted in zip (self .parts , self .is_quoted ):
8082 if isinstance (part , Star ):
@@ -86,9 +88,10 @@ def parts_to_str(self):
8688 or part .upper () in reserved_words
8789 ):
8890 part = f'`{ part } `'
91+ yield part
8992
90- out_parts . append ( part )
91- return '.' .join (out_parts )
93+ def parts_to_str ( self ):
94+ return '.' .join (self . iter_parts_str () )
9295
9396 def to_tree (self , * args , level = 0 , ** kwargs ):
9497 alias_str = f', alias={ self .alias .to_tree ()} ' if self .alias else ''
0 commit comments