File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 2222 DelimitedList ,
2323 Group ,
2424 MatchFirst ,
25+ ParseException ,
2526 ParserElement ,
2627 ParseResults ,
28+ QuotedString ,
2729 Suppress ,
2830 Word ,
2931 alphanums ,
7981LIKE = CaselessKeyword ("like" )
8082
8183unquoted_identifier = Word (alphas + "_" , alphanums + "_$" )
82- quoted_identifier = Suppress ('"' ) + unquoted_identifier + Suppress ('"' )
84+ quoted_identifier = QuotedString ('"' , escChar = "\\ " , unquoteResults = True )
85+
86+
87+ @quoted_identifier .set_parse_action
88+ def validate_quoted_identifier (result : ParseResults ) -> str :
89+ if "." in result [0 ]:
90+ raise ParseException ("Expected '\" ', found '.'" )
91+ return result [0 ]
92+
93+
8394identifier = MatchFirst ([unquoted_identifier , quoted_identifier ]).set_results_name ("identifier" )
8495column = DelimitedList (identifier , delim = "." , combine = False ).set_results_name ("column" )
8596
Original file line number Diff line number Diff line change @@ -230,9 +230,11 @@ def test_quoted_column_with_dots() -> None:
230230 with pytest .raises (ParseException ) as exc_info :
231231 parser .parse ("\" foo.bar\" .baz = 'data'" )
232232
233- assert "Expected '\" ', found '.'" in str (exc_info .value )
234-
235233 with pytest .raises (ParseException ) as exc_info :
236234 parser .parse ("'foo.bar'.baz = 'data'" )
237235
238236 assert "Expected <= | <> | < | >= | > | == | = | !=, found '.'" in str (exc_info .value )
237+
238+
239+ def test_quoted_column_with_spaces () -> None :
240+ assert EqualTo ("Foo Bar" , "data" ) == parser .parse ("\" Foo Bar\" = 'data'" )
You can’t perform that action at this time.
0 commit comments