@@ -42,7 +42,7 @@ mod test_utils;
42
42
43
43
#[ cfg( test) ]
44
44
use pretty_assertions:: assert_eq;
45
- use sqlparser:: ast:: Expr :: Identifier ;
45
+ use sqlparser:: ast:: Expr :: { Identifier , UnaryOp } ;
46
46
use sqlparser:: test_utils:: all_dialects_except;
47
47
48
48
#[ test]
@@ -4779,6 +4779,33 @@ fn parse_aggregate_with_group_by() {
4779
4779
//TODO: assertions
4780
4780
}
4781
4781
4782
+ #[ test]
4783
+ fn parse_literal_integer ( ) {
4784
+ let sql = "SELECT 1, -10, +20" ;
4785
+ let select = verified_only_select ( sql) ;
4786
+ assert_eq ! ( 3 , select. projection. len( ) ) ;
4787
+ assert_eq ! (
4788
+ & Expr :: Value ( number( "1" ) ) ,
4789
+ expr_from_projection( & select. projection[ 0 ] ) ,
4790
+ ) ;
4791
+ // negative literal is parsed as a - and expr
4792
+ assert_eq ! (
4793
+ & UnaryOp {
4794
+ op: UnaryOperator :: Minus ,
4795
+ expr: Box :: new( Expr :: Value ( number( "10" ) ) )
4796
+ } ,
4797
+ expr_from_projection( & select. projection[ 1 ] ) ,
4798
+ ) ;
4799
+ // positive literal is parsed as a + and expr
4800
+ assert_eq ! (
4801
+ & UnaryOp {
4802
+ op: UnaryOperator :: Plus ,
4803
+ expr: Box :: new( Expr :: Value ( number( "20" ) ) )
4804
+ } ,
4805
+ expr_from_projection( & select. projection[ 2 ] ) ,
4806
+ )
4807
+ }
4808
+
4782
4809
#[ test]
4783
4810
fn parse_literal_decimal ( ) {
4784
4811
// These numbers were explicitly chosen to not roundtrip if represented as
0 commit comments