File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1287,10 +1287,17 @@ impl<'a> Tokenizer<'a> {
12871287 chars. next ( ) ; // consume the dot
12881288
12891289 match chars. peek ( ) {
1290- Some ( '_' ) => {
1291- // Handle "._" case as a period (special token) followed by identifier
1290+ // Handle "._" case as a period followed by identifier
1291+ // if the last token was a word
1292+ Some ( '_' ) if matches ! ( prev_token, Some ( Token :: Word ( _) ) ) => {
12921293 Ok ( Some ( Token :: Period ) )
12931294 }
1295+ Some ( '_' ) => {
1296+ self . tokenizer_error (
1297+ chars. location ( ) ,
1298+ "Unexpected an underscore here" . to_string ( ) ,
1299+ )
1300+ }
12941301 Some ( ch)
12951302 // Hive and mysql dialects allow numeric prefixes for identifers
12961303 if ch. is_ascii_digit ( )
@@ -2504,6 +2511,16 @@ mod tests {
25042511 ] ;
25052512
25062513 compare ( expected, tokens) ;
2514+
2515+ let sql = String :: from ( "SELECT ._123" ) ;
2516+ if let Ok ( tokens) = Tokenizer :: new ( & dialect, & sql) . tokenize ( ) {
2517+ panic ! ( "Tokenizer should have failed on {sql}, but it succeeded with {tokens:?}" ) ;
2518+ }
2519+
2520+ let sql = String :: from ( "SELECT ._abc" ) ;
2521+ if let Ok ( tokens) = Tokenizer :: new ( & dialect, & sql) . tokenize ( ) {
2522+ panic ! ( "Tokenizer should have failed on {sql}, but it succeeded with {tokens:?}" ) ;
2523+ }
25072524 }
25082525
25092526 #[ test]
You can’t perform that action at this time.
0 commit comments