@@ -6669,13 +6669,12 @@ def _build_json_extract(
66696669 self ,
66706670 this : exp .Expr | None ,
66716671 path_parts : list [exp .JSONPathPart ],
6672- escape : bool | None ,
66736672 ) -> tuple [exp .Expr | None , list [exp .JSONPathPart ]]:
66746673 if len (path_parts ) > 1 :
66756674 this = self .expression (
66766675 exp .JSONExtract (
66776676 this = this ,
6678- expression = exp .JSONPath (expressions = path_parts , escape = escape ),
6677+ expression = exp .JSONPath (expressions = path_parts ),
66796678 variant_extract = True ,
66806679 requires_json = self .JSON_EXTRACT_REQUIRES_JSON_EXPRESSION ,
66816680 )
@@ -6686,28 +6685,24 @@ def _build_json_extract(
66866685
66876686 def _parse_colon_as_variant_extract (self , this : exp .Expr | None ) -> exp .Expr | None :
66886687 path_parts : list [exp .JSONPathPart ] = [exp .JSONPathRoot ()]
6689- escape = None
66906688
66916689 while self ._match (TokenType .COLON ):
66926690 if not self .COLON_CHAIN_IS_SINGLE_EXTRACT :
6693- this , path_parts = self ._build_json_extract (this , path_parts , escape )
6694- escape = None
6691+ this , path_parts = self ._build_json_extract (this , path_parts )
66956692
66966693 key = self ._parse_id_var (any_token = True , tokens = (TokenType .SELECT ,))
66976694
66986695 if key :
6699- if isinstance (key , exp .Identifier ) and key .quoted :
6700- escape = True
6701- path_parts .append (exp .JSONPathKey (this = key .name ))
6696+ quoted = isinstance (key , exp .Identifier ) and key .quoted
6697+ path_parts .append (exp .JSONPathKey (this = key .name , quoted = quoted ))
67026698
67036699 while True :
67046700 if self ._match (TokenType .DOT ):
67056701 next_key = self ._parse_id_var (any_token = True , tokens = (TokenType .SELECT ,))
67066702
67076703 if next_key :
6708- if isinstance (next_key , exp .Identifier ) and next_key .quoted :
6709- escape = True
6710- path_parts .append (exp .JSONPathKey (this = next_key .name ))
6704+ quoted = isinstance (next_key , exp .Identifier ) and next_key .quoted
6705+ path_parts .append (exp .JSONPathKey (this = next_key .name , quoted = quoted ))
67116706 elif self ._match (TokenType .L_BRACKET ):
67126707 bracket_expr = self ._parse_bracket_key_value ()
67136708
@@ -6716,15 +6711,13 @@ def _parse_colon_as_variant_extract(self, this: exp.Expr | None) -> exp.Expr | N
67166711
67176712 if bracket_expr :
67186713 if bracket_expr .is_string :
6719- path_parts .append (exp .JSONPathKey (this = bracket_expr .name ))
6720- escape = True
6714+ path_parts .append (exp .JSONPathKey (this = bracket_expr .name , quoted = True ))
67216715 elif bracket_expr .is_star :
67226716 path_parts .append (exp .JSONPathSubscript (this = exp .JSONPathWildcard ()))
67236717 elif bracket_expr .is_number :
67246718 path_parts .append (exp .JSONPathSubscript (this = bracket_expr .to_py ()))
67256719 else :
6726- this , path_parts = self ._build_json_extract (this , path_parts , escape )
6727- escape = None
6720+ this , path_parts = self ._build_json_extract (this , path_parts )
67286721
67296722 this = self .expression (
67306723 exp .Bracket (
@@ -6733,8 +6726,7 @@ def _parse_colon_as_variant_extract(self, this: exp.Expr | None) -> exp.Expr | N
67336726 )
67346727
67356728 elif self ._match (TokenType .DCOLON ):
6736- this , path_parts = self ._build_json_extract (this , path_parts , escape )
6737- escape = None
6729+ this , path_parts = self ._build_json_extract (this , path_parts )
67386730
67396731 cast_type = self ._parse_types ()
67406732 if cast_type :
@@ -6744,7 +6736,7 @@ def _parse_colon_as_variant_extract(self, this: exp.Expr | None) -> exp.Expr | N
67446736 else :
67456737 break
67466738
6747- this , _ = self ._build_json_extract (this , path_parts , escape )
6739+ this , _ = self ._build_json_extract (this , path_parts )
67486740
67496741 return this
67506742
0 commit comments