File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -67,8 +67,13 @@ pub enum DataType {
67
67
UnsignedBigInt ( Option < u64 > ) ,
68
68
/// Floating point e.g. REAL
69
69
Real ,
70
- /// Double e.g. DOUBLE PRECISION
70
+ /// Double
71
71
Double ,
72
+ /// Double PRECISION e.g. [standard], [postgresql]
73
+ ///
74
+ /// [standard]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#approximate-numeric-type
75
+ /// [postgresql]: https://www.postgresql.org/docs/current/datatype-numeric.html
76
+ DoublePrecision ,
72
77
/// Boolean
73
78
Boolean ,
74
79
/// Date
@@ -154,6 +159,7 @@ impl fmt::Display for DataType {
154
159
}
155
160
DataType :: Real => write ! ( f, "REAL" ) ,
156
161
DataType :: Double => write ! ( f, "DOUBLE" ) ,
162
+ DataType :: DoublePrecision => write ! ( f, "DOUBLE PRECISION" ) ,
157
163
DataType :: Boolean => write ! ( f, "BOOLEAN" ) ,
158
164
DataType :: Date => write ! ( f, "DATE" ) ,
159
165
DataType :: Time => write ! ( f, "TIME" ) ,
Original file line number Diff line number Diff line change @@ -3338,8 +3338,11 @@ impl<'a> Parser<'a> {
3338
3338
Keyword :: FLOAT => Ok ( DataType :: Float ( self . parse_optional_precision ( ) ?) ) ,
3339
3339
Keyword :: REAL => Ok ( DataType :: Real ) ,
3340
3340
Keyword :: DOUBLE => {
3341
- let _ = self . parse_keyword ( Keyword :: PRECISION ) ;
3342
- Ok ( DataType :: Double )
3341
+ if self . parse_keyword ( Keyword :: PRECISION ) {
3342
+ Ok ( DataType :: DoublePrecision )
3343
+ } else {
3344
+ Ok ( DataType :: Double )
3345
+ }
3343
3346
}
3344
3347
Keyword :: TINYINT => {
3345
3348
let optional_precision = self . parse_optional_precision ( ) ;
@@ -5241,4 +5244,18 @@ mod tests {
5241
5244
assert_eq ! ( ast. to_string( ) , sql. to_string( ) ) ;
5242
5245
} ) ;
5243
5246
}
5247
+
5248
+ // TODO add tests for all data types? https://github.com/sqlparser-rs/sqlparser-rs/issues/2
5249
+ #[ test]
5250
+ fn test_parse_data_type ( ) {
5251
+ test_parse_data_type ( "DOUBLE PRECISION" , "DOUBLE PRECISION" ) ;
5252
+ test_parse_data_type ( "DOUBLE" , "DOUBLE" ) ;
5253
+
5254
+ fn test_parse_data_type ( input : & str , expected : & str ) {
5255
+ all_dialects ( ) . run_parser_method ( input, |parser| {
5256
+ let data_type = parser. parse_data_type ( ) . unwrap ( ) . to_string ( ) ;
5257
+ assert_eq ! ( data_type, expected) ;
5258
+ } ) ;
5259
+ }
5260
+ }
5244
5261
}
You can’t perform that action at this time.
0 commit comments