File tree 2 files changed +51
-0
lines changed 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -3390,6 +3390,10 @@ impl<'a> Parser<'a> {
3390
3390
Ok ( DataType :: Char ( self . parse_optional_precision ( ) ?) )
3391
3391
}
3392
3392
}
3393
+ Keyword :: CLOB => Ok ( DataType :: Clob ( self . parse_precision ( ) ?) ) ,
3394
+ Keyword :: BINARY => Ok ( DataType :: Binary ( self . parse_precision ( ) ?) ) ,
3395
+ Keyword :: VARBINARY => Ok ( DataType :: Varbinary ( self . parse_precision ( ) ?) ) ,
3396
+ Keyword :: BLOB => Ok ( DataType :: Blob ( self . parse_precision ( ) ?) ) ,
3393
3397
Keyword :: UUID => Ok ( DataType :: Uuid ) ,
3394
3398
Keyword :: DATE => Ok ( DataType :: Date ) ,
3395
3399
Keyword :: DATETIME => Ok ( DataType :: Datetime ) ,
@@ -3603,6 +3607,13 @@ impl<'a> Parser<'a> {
3603
3607
}
3604
3608
}
3605
3609
3610
+ pub fn parse_precision ( & mut self ) -> Result < u64 , ParserError > {
3611
+ self . expect_token ( & Token :: LParen ) ?;
3612
+ let n = self . parse_literal_uint ( ) ?;
3613
+ self . expect_token ( & Token :: RParen ) ?;
3614
+ Ok ( n)
3615
+ }
3616
+
3606
3617
pub fn parse_optional_precision ( & mut self ) -> Result < Option < u64 > , ParserError > {
3607
3618
if self . consume_token ( & Token :: LParen ) {
3608
3619
let n = self . parse_literal_uint ( ) ?;
Original file line number Diff line number Diff line change @@ -1649,6 +1649,46 @@ fn parse_cast() {
1649
1649
} ,
1650
1650
expr_from_projection( only( & select. projection) )
1651
1651
) ;
1652
+
1653
+ let sql = "SELECT CAST(id AS CLOB(50)) FROM customer" ;
1654
+ let select = verified_only_select ( sql) ;
1655
+ assert_eq ! (
1656
+ & Expr :: Cast {
1657
+ expr: Box :: new( Expr :: Identifier ( Ident :: new( "id" ) ) ) ,
1658
+ data_type: DataType :: Clob ( 50 )
1659
+ } ,
1660
+ expr_from_projection( only( & select. projection) )
1661
+ ) ;
1662
+
1663
+ let sql = "SELECT CAST(id AS BINARY(50)) FROM customer" ;
1664
+ let select = verified_only_select ( sql) ;
1665
+ assert_eq ! (
1666
+ & Expr :: Cast {
1667
+ expr: Box :: new( Expr :: Identifier ( Ident :: new( "id" ) ) ) ,
1668
+ data_type: DataType :: Binary ( 50 )
1669
+ } ,
1670
+ expr_from_projection( only( & select. projection) )
1671
+ ) ;
1672
+
1673
+ let sql = "SELECT CAST(id AS VARBINARY(50)) FROM customer" ;
1674
+ let select = verified_only_select ( sql) ;
1675
+ assert_eq ! (
1676
+ & Expr :: Cast {
1677
+ expr: Box :: new( Expr :: Identifier ( Ident :: new( "id" ) ) ) ,
1678
+ data_type: DataType :: Varbinary ( 50 )
1679
+ } ,
1680
+ expr_from_projection( only( & select. projection) )
1681
+ ) ;
1682
+
1683
+ let sql = "SELECT CAST(id AS BLOB(50)) FROM customer" ;
1684
+ let select = verified_only_select ( sql) ;
1685
+ assert_eq ! (
1686
+ & Expr :: Cast {
1687
+ expr: Box :: new( Expr :: Identifier ( Ident :: new( "id" ) ) ) ,
1688
+ data_type: DataType :: Blob ( 50 )
1689
+ } ,
1690
+ expr_from_projection( only( & select. projection) )
1691
+ ) ;
1652
1692
}
1653
1693
1654
1694
#[ test]
You can’t perform that action at this time.
0 commit comments