File tree 3 files changed +28
-12
lines changed
3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -433,15 +433,14 @@ impl fmt::Display for WindowSpec {
433
433
write ! ( f, "ORDER BY {}" , display_comma_separated( & self . order_by) ) ?;
434
434
}
435
435
if let Some ( window_frame) = & self . window_frame {
436
+ f. write_str ( delim) ?;
436
437
if let Some ( end_bound) = & window_frame. end_bound {
437
- f. write_str ( delim) ?;
438
438
write ! (
439
439
f,
440
440
"{} BETWEEN {} AND {}" ,
441
441
window_frame. units, window_frame. start_bound, end_bound
442
442
) ?;
443
443
} else {
444
- f. write_str ( delim) ?;
445
444
write ! ( f, "{} {}" , window_frame. units, window_frame. start_bound) ?;
446
445
}
447
446
}
Original file line number Diff line number Diff line change @@ -1620,9 +1620,10 @@ impl<'a> Parser<'a> {
1620
1620
loop {
1621
1621
if let Some ( constraint) = self . parse_optional_table_constraint ( ) ? {
1622
1622
constraints. push ( constraint) ;
1623
- } else if let Token :: Word ( _) = self . peek_token ( ) {
1624
- columns. push ( self . parse_column_def ( ) ?) ;
1625
- } else if let Token :: BackQuotedString ( _) = self . peek_token ( ) {
1623
+ } else if matches ! (
1624
+ self . peek_token( ) ,
1625
+ Token :: Word ( _) | Token :: BackQuotedString ( _)
1626
+ ) {
1626
1627
columns. push ( self . parse_column_def ( ) ?) ;
1627
1628
} else {
1628
1629
return self . expected ( "column name or constraint definition" , self . peek_token ( ) ) ;
@@ -2793,10 +2794,10 @@ impl<'a> Parser<'a> {
2793
2794
// followed by some joins or (B) another level of nesting.
2794
2795
let mut table_and_joins = self . parse_table_and_joins ( ) ?;
2795
2796
2796
- if !table_and_joins. joins . is_empty ( ) {
2797
- self . expect_token ( & Token :: RParen ) ? ;
2798
- Ok ( TableFactor :: NestedJoin ( Box :: new ( table_and_joins ) ) ) // (A)
2799
- } else if let TableFactor :: NestedJoin ( _ ) = & table_and_joins . relation {
2797
+ if !table_and_joins. joins . is_empty ( )
2798
+ || matches ! ( & table_and_joins . relation , TableFactor :: NestedJoin ( _ ) )
2799
+ {
2800
+ // (A)
2800
2801
// (B): `table_and_joins` (what we found inside the parentheses)
2801
2802
// is a nested join `(foo JOIN bar)`, not followed by other joins.
2802
2803
self . expect_token ( & Token :: RParen ) ?;
Original file line number Diff line number Diff line change @@ -643,10 +643,9 @@ impl<'a> Tokenizer<'a> {
643
643
) -> Result < String , TokenizerError > {
644
644
let mut s = String :: new ( ) ;
645
645
chars. next ( ) ; // consume the opening quote
646
- while let Some ( & ch) = chars. peek ( ) {
646
+ while let Some ( ch) = chars. next ( ) {
647
647
match ch {
648
648
'\'' => {
649
- chars. next ( ) ; // consume
650
649
let escaped_quote = chars. peek ( ) . map ( |c| * c == '\'' ) . unwrap_or ( false ) ;
651
650
if escaped_quote {
652
651
s. push ( '\'' ) ;
@@ -655,8 +654,25 @@ impl<'a> Tokenizer<'a> {
655
654
return Ok ( s) ;
656
655
}
657
656
}
657
+ '\\' => {
658
+ if let Some ( c) = chars. next ( ) {
659
+ match c {
660
+ 'n' => s. push ( '\n' ) ,
661
+ 't' => s. push ( '\t' ) ,
662
+ 'r' => s. push ( '\r' ) ,
663
+ 'b' => s. push ( '\u{08}' ) ,
664
+ '0' => s. push ( '\0' ) ,
665
+ '\'' => s. push ( '\'' ) ,
666
+ '\\' => s. push ( '\\' ) ,
667
+ '\"' => s. push ( '\"' ) ,
668
+ _ => {
669
+ s. push ( '\\' ) ;
670
+ s. push ( c) ;
671
+ }
672
+ }
673
+ }
674
+ }
658
675
_ => {
659
- chars. next ( ) ; // consume
660
676
s. push ( ch) ;
661
677
}
662
678
}
You can’t perform that action at this time.
0 commit comments