@@ -62,77 +62,78 @@ pub enum ColType {
62
62
PkAuto ,
63
63
PkUuid ,
64
64
CharLen ( u32 ) ,
65
+ CharLenWithDefault ( u32 , char ) ,
65
66
CharLenNull ( u32 ) ,
66
67
CharLenUniq ( u32 ) ,
67
68
Char ,
69
+ CharWithDefault ( char ) ,
68
70
CharNull ,
69
71
CharUniq ,
70
72
StringLen ( u32 ) ,
73
+ StringLenWithDefault ( u32 , String ) ,
71
74
StringLenNull ( u32 ) ,
72
75
StringLenUniq ( u32 ) ,
73
76
String ,
77
+ StringWithDefault ( String ) ,
74
78
StringNull ,
75
79
StringUniq ,
76
80
Text ,
81
+ TextWithDefault ( String ) ,
77
82
TextNull ,
78
83
TextUniq ,
79
84
Integer ,
85
+ IntegerWithDefault ( i32 ) ,
80
86
IntegerNull ,
81
87
IntegerUniq ,
82
88
Unsigned ,
89
+ UnsignedWithDefault ( u32 ) ,
83
90
UnsignedNull ,
84
91
UnsignedUniq ,
85
- // Tiny fields are not supported due to differences in data types between PostgreSQL and SQLite:
86
- // * Postgres: i16
87
- // * Sqlite: i8
88
- // TinyUnsigned,
89
- // TinyUnsignedNull,
90
- // TinyUnsignedUniq,
91
92
SmallUnsigned ,
93
+ SmallUnsignedWithDefault ( u16 ) ,
92
94
SmallUnsignedNull ,
93
95
SmallUnsignedUniq ,
94
96
BigUnsigned ,
97
+ BigUnsignedWithDefault ( u64 ) ,
95
98
BigUnsignedNull ,
96
99
BigUnsignedUniq ,
97
- // Tiny fields are not supported due to differences in data types between PostgreSQL and SQLite:
98
- // * Postgres: i16
99
- // * Sqlite: i8
100
- // TinyInteger,
101
- // TinyIntegerNull,
102
- // TinyIntegerUniq,
103
100
SmallInteger ,
101
+ SmallIntegerWithDefault ( i16 ) ,
104
102
SmallIntegerNull ,
105
103
SmallIntegerUniq ,
106
104
BigInteger ,
105
+ BigIntegerWithDefault ( i64 ) ,
107
106
BigIntegerNull ,
108
107
BigIntegerUniq ,
109
108
Decimal ,
109
+ DecimalWithDefault ( f64 ) ,
110
110
DecimalNull ,
111
111
DecimalUniq ,
112
112
DecimalLen ( u32 , u32 ) ,
113
+ DecimalLenWithDefault ( u32 , u32 , f64 ) ,
113
114
DecimalLenNull ( u32 , u32 ) ,
114
115
DecimalLenUniq ( u32 , u32 ) ,
115
116
Float ,
117
+ FloatWithDefault ( f32 ) ,
116
118
FloatNull ,
117
119
FloatUniq ,
118
120
Double ,
121
+ DoubleWithDefault ( f64 ) ,
119
122
DoubleNull ,
120
123
DoubleUniq ,
121
124
Boolean ,
125
+ BooleanWithDefault ( bool ) ,
122
126
BooleanNull ,
123
- // Timestamp fields are not supported due to differences in data types between PostgreSQL and SQLite:
124
- // * Postgres: DateTime
125
- // * Sqlite: DateTimeUtc
126
- // Timestamp,
127
- // TimestampNull,
128
- // TimestampUniq,
129
127
Date ,
128
+ DateWithDefault ( String ) ,
130
129
DateNull ,
131
130
DateUniq ,
132
131
DateTime ,
132
+ DateTimeWithDefault ( String ) ,
133
133
DateTimeNull ,
134
134
DateTimeUniq ,
135
135
Time ,
136
+ TimeWithDefault ( String ) ,
136
137
TimeNull ,
137
138
TimeUniq ,
138
139
Interval ( Option < PgInterval > , Option < u32 > ) ,
@@ -147,8 +148,8 @@ pub enum ColType {
147
148
VarBinary ( u32 ) ,
148
149
VarBinaryNull ( u32 ) ,
149
150
VarBinaryUniq ( u32 ) ,
150
- // Added variants based on the JSON
151
151
TimestampWithTimeZone ,
152
+ TimestampWithTimeZoneWithDefault ( String ) ,
152
153
TimestampWithTimeZoneNull ,
153
154
Json ,
154
155
JsonNull ,
@@ -160,6 +161,7 @@ pub enum ColType {
160
161
BlobNull ,
161
162
BlobUniq ,
162
163
Money ,
164
+ MoneyWithDefault ( f64 ) ,
163
165
MoneyNull ,
164
166
MoneyUniq ,
165
167
Uuid ,
@@ -317,6 +319,30 @@ impl ColType {
317
319
Self :: Array ( kind) => array ( name, kind. clone ( ) ) ,
318
320
Self :: ArrayNull ( kind) => array_null ( name, kind. clone ( ) ) ,
319
321
Self :: ArrayUniq ( kind) => array_uniq ( name, kind. clone ( ) ) ,
322
+ // defaults
323
+ Self :: MoneyWithDefault ( v) => money ( name) . default ( * v) . take ( ) ,
324
+ Self :: IntegerWithDefault ( v) => integer ( name) . default ( * v) . take ( ) ,
325
+ Self :: UnsignedWithDefault ( v) => unsigned ( name) . default ( * v) . take ( ) ,
326
+ Self :: SmallUnsignedWithDefault ( v) => small_unsigned ( name) . default ( * v) . take ( ) ,
327
+ Self :: BigUnsignedWithDefault ( v) => big_unsigned ( name) . default ( * v) . take ( ) ,
328
+ Self :: SmallIntegerWithDefault ( v) => small_integer ( name) . default ( * v) . take ( ) ,
329
+ Self :: BigIntegerWithDefault ( v) => big_integer ( name) . default ( * v) . take ( ) ,
330
+ Self :: DecimalWithDefault ( v) => decimal ( name) . default ( * v) . take ( ) ,
331
+ Self :: DecimalLenWithDefault ( p, s, v) => decimal_len ( name, * p, * s) . default ( * v) . take ( ) ,
332
+ Self :: FloatWithDefault ( v) => float ( name) . default ( * v) . take ( ) ,
333
+ Self :: DoubleWithDefault ( v) => double ( name) . default ( * v) . take ( ) ,
334
+ Self :: BooleanWithDefault ( v) => boolean ( name) . default ( * v) . take ( ) ,
335
+ Self :: DateWithDefault ( v) => date ( name) . default ( v. clone ( ) ) . take ( ) ,
336
+ Self :: DateTimeWithDefault ( v) => date_time ( name) . default ( v. clone ( ) ) . take ( ) ,
337
+ Self :: TimeWithDefault ( v) => time ( name) . default ( v. clone ( ) ) . take ( ) ,
338
+ Self :: TimestampWithTimeZoneWithDefault ( v) => {
339
+ timestamptz ( name) . default ( v. clone ( ) ) . take ( )
340
+ }
341
+ Self :: CharWithDefault ( v) => char ( name) . default ( * v) . take ( ) ,
342
+ Self :: CharLenWithDefault ( len, v) => char_len ( name, * len) . default ( * v) . take ( ) ,
343
+ Self :: StringWithDefault ( v) => string ( name) . default ( v. clone ( ) ) . take ( ) ,
344
+ Self :: StringLenWithDefault ( len, v) => string_len ( name, * len) . default ( v. clone ( ) ) . take ( ) ,
345
+ Self :: TextWithDefault ( v) => text ( name) . default ( v. clone ( ) ) . take ( ) ,
320
346
}
321
347
}
322
348
}
0 commit comments