File tree 1 file changed +19
-2
lines changed
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> {
1287
1287
chars. next ( ) ; // consume the dot
1288
1288
1289
1289
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 ( _) ) ) => {
1292
1293
Ok ( Some ( Token :: Period ) )
1293
1294
}
1295
+ Some ( '_' ) => {
1296
+ self . tokenizer_error (
1297
+ chars. location ( ) ,
1298
+ "Unexpected an underscore here" . to_string ( ) ,
1299
+ )
1300
+ }
1294
1301
Some ( ch)
1295
1302
// Hive and mysql dialects allow numeric prefixes for identifers
1296
1303
if ch. is_ascii_digit ( )
@@ -2504,6 +2511,16 @@ mod tests {
2504
2511
] ;
2505
2512
2506
2513
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
+ }
2507
2524
}
2508
2525
2509
2526
#[ test]
You can’t perform that action at this time.
0 commit comments