File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ pub enum SQLType {
17
17
Varbinary ( usize ) ,
18
18
/// Large binary object e.g. BLOB(1000)
19
19
Blob ( usize ) ,
20
- /// Decimal type with precision and optional scale e.g. DECIMAL(10,2)
21
- Decimal ( usize , Option < usize > ) ,
20
+ /// Decimal type with optional precision and scale e.g. DECIMAL(10,2)
21
+ Decimal ( Option < usize > , Option < usize > ) ,
22
22
/// Small integer
23
23
SmallInt ,
24
24
/// Integer
@@ -75,9 +75,13 @@ impl ToString for SQLType {
75
75
SQLType :: Blob ( size) => format ! ( "blob({})" , size) ,
76
76
SQLType :: Decimal ( precision, scale) => {
77
77
if let Some ( scale) = scale {
78
- format ! ( "numeric({},{})" , precision, scale)
78
+ format ! ( "numeric({},{})" , precision. unwrap ( ) , scale)
79
79
} else {
80
- format ! ( "numeric({})" , precision)
80
+ if let Some ( precision) = precision {
81
+ format ! ( "numeric({})" , precision)
82
+ } else {
83
+ format ! ( "numeric" )
84
+ }
81
85
}
82
86
}
83
87
SQLType :: SmallInt => "smallint" . to_string ( ) ,
Original file line number Diff line number Diff line change @@ -1166,7 +1166,7 @@ impl Parser {
1166
1166
1167
1167
pub fn parse_optional_precision_scale (
1168
1168
& mut self ,
1169
- ) -> Result < ( usize , Option < usize > ) , ParserError > {
1169
+ ) -> Result < ( Option < usize > , Option < usize > ) , ParserError > {
1170
1170
if self . consume_token ( & Token :: LParen ) {
1171
1171
let n = self . parse_literal_int ( ) ?;
1172
1172
let scale = if self . consume_token ( & Token :: Comma ) {
@@ -1175,9 +1175,9 @@ impl Parser {
1175
1175
None
1176
1176
} ;
1177
1177
self . expect_token ( & Token :: RParen ) ?;
1178
- Ok ( ( n as usize , scale) )
1178
+ Ok ( ( Some ( n as usize ) , scale) )
1179
1179
} else {
1180
- parser_err ! ( "Expecting `(`" )
1180
+ Ok ( ( None , None ) )
1181
1181
}
1182
1182
}
1183
1183
You can’t perform that action at this time.
0 commit comments