@@ -131,6 +131,11 @@ pub enum DataType {
131
131
///
132
132
/// [1]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#exact-numeric-type
133
133
Decimal ( ExactNumberInfo ) ,
134
+ /// [MySQL] unsigned decimal with optional precision and scale, e.g. DECIMAL UNSIGNED or DECIMAL(10,2) UNSIGNED.
135
+ /// Note: Using UNSIGNED with DECIMAL is deprecated in recent versions of MySQL.
136
+ ///
137
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html
138
+ DecimalUnsigned ( ExactNumberInfo ) ,
134
139
/// [BigNumeric] type used in BigQuery.
135
140
///
136
141
/// [BigNumeric]: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#bignumeric_literals
@@ -143,8 +148,19 @@ pub enum DataType {
143
148
///
144
149
/// [1]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#exact-numeric-type
145
150
Dec ( ExactNumberInfo ) ,
146
- /// Floating point with optional precision, e.g. FLOAT(8).
147
- Float ( Option < u64 > ) ,
151
+ /// [MySQL] unsigned decimal (DEC alias) with optional precision and scale, e.g. DEC UNSIGNED or DEC(10,2) UNSIGNED.
152
+ /// Note: Using UNSIGNED with DEC is deprecated in recent versions of MySQL.
153
+ ///
154
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html
155
+ DecUnsigned ( ExactNumberInfo ) ,
156
+ /// Floating point with optional precision and scale, e.g. FLOAT, FLOAT(8), or FLOAT(8,2).
157
+ Float ( ExactNumberInfo ) ,
158
+ /// [MySQL] unsigned floating point with optional precision and scale, e.g.
159
+ /// FLOAT UNSIGNED, FLOAT(10) UNSIGNED or FLOAT(10,2) UNSIGNED.
160
+ /// Note: Using UNSIGNED with FLOAT is deprecated in recent versions of MySQL.
161
+ ///
162
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html
163
+ FloatUnsigned ( ExactNumberInfo ) ,
148
164
/// Tiny integer with optional display width, e.g. TINYINT or TINYINT(3).
149
165
TinyInt ( Option < u64 > ) ,
150
166
/// Unsigned tiny integer with optional display width,
@@ -302,17 +318,32 @@ pub enum DataType {
302
318
Float64 ,
303
319
/// Floating point, e.g. REAL.
304
320
Real ,
321
+ /// [MySQL] unsigned real, e.g. REAL UNSIGNED.
322
+ /// Note: Using UNSIGNED with REAL is deprecated in recent versions of MySQL.
323
+ ///
324
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html
325
+ RealUnsigned ,
305
326
/// Float8 is an alias for Double in [PostgreSQL].
306
327
///
307
328
/// [PostgreSQL]: https://www.postgresql.org/docs/current/datatype.html
308
329
Float8 ,
309
330
/// Double
310
331
Double ( ExactNumberInfo ) ,
332
+ /// [MySQL] unsigned double precision with optional precision, e.g. DOUBLE UNSIGNED or DOUBLE(10,2) UNSIGNED.
333
+ /// Note: Using UNSIGNED with DOUBLE is deprecated in recent versions of MySQL.
334
+ ///
335
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html
336
+ DoubleUnsigned ( ExactNumberInfo ) ,
311
337
/// Double Precision, see [SQL Standard], [PostgreSQL].
312
338
///
313
339
/// [SQL Standard]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#approximate-numeric-type
314
340
/// [PostgreSQL]: https://www.postgresql.org/docs/current/datatype-numeric.html
315
341
DoublePrecision ,
342
+ /// [MySQL] unsigned double precision, e.g. DOUBLE PRECISION UNSIGNED.
343
+ /// Note: Using UNSIGNED with DOUBLE PRECISION is deprecated in recent versions of MySQL.
344
+ ///
345
+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/numeric-type-syntax.html
346
+ DoublePrecisionUnsigned ,
316
347
/// Bool is an alias for Boolean, see [PostgreSQL].
317
348
///
318
349
/// [PostgreSQL]: https://www.postgresql.org/docs/current/datatype.html
@@ -497,12 +528,19 @@ impl fmt::Display for DataType {
497
528
DataType :: Decimal ( info) => {
498
529
write ! ( f, "DECIMAL{info}" )
499
530
}
531
+ DataType :: DecimalUnsigned ( info) => {
532
+ write ! ( f, "DECIMAL{info} UNSIGNED" )
533
+ }
500
534
DataType :: Dec ( info) => {
501
535
write ! ( f, "DEC{info}" )
502
536
}
537
+ DataType :: DecUnsigned ( info) => {
538
+ write ! ( f, "DEC{info} UNSIGNED" )
539
+ }
503
540
DataType :: BigNumeric ( info) => write ! ( f, "BIGNUMERIC{info}" ) ,
504
541
DataType :: BigDecimal ( info) => write ! ( f, "BIGDECIMAL{info}" ) ,
505
- DataType :: Float ( size) => format_type_with_optional_length ( f, "FLOAT" , size, false ) ,
542
+ DataType :: Float ( info) => write ! ( f, "FLOAT{info}" ) ,
543
+ DataType :: FloatUnsigned ( info) => write ! ( f, "FLOAT{info} UNSIGNED" ) ,
506
544
DataType :: TinyInt ( zerofill) => {
507
545
format_type_with_optional_length ( f, "TINYINT" , zerofill, false )
508
546
}
@@ -616,12 +654,15 @@ impl fmt::Display for DataType {
616
654
write ! ( f, "UNSIGNED INTEGER" )
617
655
}
618
656
DataType :: Real => write ! ( f, "REAL" ) ,
657
+ DataType :: RealUnsigned => write ! ( f, "REAL UNSIGNED" ) ,
619
658
DataType :: Float4 => write ! ( f, "FLOAT4" ) ,
620
659
DataType :: Float32 => write ! ( f, "Float32" ) ,
621
660
DataType :: Float64 => write ! ( f, "FLOAT64" ) ,
622
661
DataType :: Double ( info) => write ! ( f, "DOUBLE{info}" ) ,
662
+ DataType :: DoubleUnsigned ( info) => write ! ( f, "DOUBLE{info} UNSIGNED" ) ,
623
663
DataType :: Float8 => write ! ( f, "FLOAT8" ) ,
624
664
DataType :: DoublePrecision => write ! ( f, "DOUBLE PRECISION" ) ,
665
+ DataType :: DoublePrecisionUnsigned => write ! ( f, "DOUBLE PRECISION UNSIGNED" ) ,
625
666
DataType :: Bool => write ! ( f, "BOOL" ) ,
626
667
DataType :: Boolean => write ! ( f, "BOOLEAN" ) ,
627
668
DataType :: Date => write ! ( f, "DATE" ) ,
0 commit comments