File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1142,9 +1142,21 @@ impl<'a> Parser<'a> {
11421142 {
11431143 let expr2 = self . parse_expr ( ) ?;
11441144 Ok ( Expr :: IsNotDistinctFrom ( Box :: new ( expr) , Box :: new ( expr2) ) )
1145+ } else if let Some ( right) =
1146+ self . parse_one_of_keywords ( & [ Keyword :: TRUE , Keyword :: FALSE ] )
1147+ {
1148+ let mut val = Value :: Boolean ( true ) ;
1149+ if right == Keyword :: FALSE {
1150+ val = Value :: Boolean ( false ) ;
1151+ }
1152+ Ok ( Expr :: BinaryOp {
1153+ left : Box :: new ( expr) ,
1154+ op : BinaryOperator :: Eq ,
1155+ right : Box :: new ( Expr :: Value ( val) ) ,
1156+ } )
11451157 } else {
11461158 self . expected (
1147- "[NOT] NULL or [NOT] DISTINCT FROM after IS" ,
1159+ "[NOT] NULL or [NOT] DISTINCT FROM TRUE FALSE after IS" ,
11481160 self . peek_token ( ) ,
11491161 )
11501162 }
Original file line number Diff line number Diff line change @@ -4717,3 +4717,25 @@ fn parse_time_functions() {
47174717 // Validating Parenthesis
47184718 one_statement_parses_to ( "SELECT CURRENT_DATE" , sql) ;
47194719}
4720+
4721+ #[ test]
4722+ fn parse_is_boolean ( ) {
4723+ one_statement_parses_to (
4724+ "SELECT f from foo where field is true" ,
4725+ "SELECT f FROM foo WHERE field = true" ,
4726+ ) ;
4727+
4728+ one_statement_parses_to (
4729+ "SELECT f from foo where field is false" ,
4730+ "SELECT f FROM foo WHERE field = false" ,
4731+ ) ;
4732+
4733+ let sql = "SELECT f from foo where field is 0" ;
4734+ let res = parse_sql_statements ( sql) ;
4735+ assert_eq ! (
4736+ ParserError :: ParserError (
4737+ "Expected [NOT] NULL or [NOT] DISTINCT FROM TRUE FALSE after IS, found: 0" . to_string( )
4738+ ) ,
4739+ res. unwrap_err( )
4740+ ) ;
4741+ }
You can’t perform that action at this time.
0 commit comments