File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -102,10 +102,15 @@ impl Dialect for MySqlDialect {
102102 ) -> Option < Result < crate :: ast:: Expr , ParserError > > {
103103 // Parse DIV as an operator
104104 if parser. parse_keyword ( Keyword :: DIV ) {
105+ let left = Box :: new ( expr. clone ( ) ) ;
106+ let right = Box :: new ( match parser. parse_expr ( ) {
107+ Ok ( expr) => expr,
108+ Err ( e) => return Some ( Err ( e) ) ,
109+ } ) ;
105110 Some ( Ok ( Expr :: BinaryOp {
106- left : Box :: new ( expr . clone ( ) ) ,
111+ left,
107112 op : BinaryOperator :: MyIntegerDivide ,
108- right : Box :: new ( parser . parse_expr ( ) . unwrap ( ) ) ,
113+ right,
109114 } ) )
110115 } else {
111116 None
Original file line number Diff line number Diff line change @@ -3627,6 +3627,14 @@ fn parse_div_infix() {
36273627 mysql ( ) . verified_stmt ( r#"SELECT 5 DIV 2"# ) ;
36283628}
36293629
3630+ #[ test]
3631+ fn parse_div_infix_propagates_parse_error ( ) {
3632+ let err = mysql ( )
3633+ . parse_sql_statements ( "SELECT 5 DIV" )
3634+ . expect_err ( "expected an error" ) ;
3635+ assert_matches ! ( err, ParserError :: ParserError ( _) ) ;
3636+ }
3637+
36303638#[ test]
36313639fn parse_drop_temporary_table ( ) {
36323640 let sql = "DROP TEMPORARY TABLE foo" ;
You can’t perform that action at this time.
0 commit comments