@@ -61,7 +61,8 @@ pub mod user_key_store;
61
61
pub mod user_role;
62
62
63
63
use diesel_impl:: { DieselArray , OptionalDieselArray } ;
64
- pub use diesel_impl:: { RequiredFromNullable , RequiredFromNullableWithDefault } ;
64
+ #[ cfg( feature = "v2" ) ]
65
+ use diesel_impl:: { RequiredFromNullable , RequiredFromNullableWithDefault } ;
65
66
66
67
pub type StorageResult < T > = error_stack:: Result < T , errors:: DatabaseError > ;
67
68
pub type PgPooledConn = async_bb8_diesel:: Connection < diesel:: PgConnection > ;
@@ -72,7 +73,6 @@ pub use self::{
72
73
payment_intent:: * , payment_method:: * , payout_attempt:: * , payouts:: * , process_tracker:: * ,
73
74
refund:: * , reverse_lookup:: * , user_authentication_method:: * ,
74
75
} ;
75
-
76
76
/// The types and implementations provided by this module are required for the schema generated by
77
77
/// `diesel_cli` 2.0 to work with the types defined in Rust code. This is because
78
78
/// [`diesel`][diesel] 2.0 [changed the nullability of array elements][diesel-2.0-array-nullability],
@@ -131,20 +131,22 @@ pub(crate) mod diesel_impl {
131
131
Ok ( Self ( row) )
132
132
}
133
133
}
134
-
134
+ # [ cfg ( feature = "v2" ) ]
135
135
/// If the DB value is null, this wrapper will return an error when deserializing.
136
136
///
137
137
/// This is useful when you want to ensure that a field is always present, even if the database
138
138
/// value is NULL. If the database column contains a NULL value, an error will be returned.
139
139
pub struct RequiredFromNullable < T > ( T ) ;
140
140
141
+ #[ cfg( feature = "v2" ) ]
141
142
impl < T > RequiredFromNullable < T > {
142
143
/// Extracts the inner value from the wrapper
143
144
pub fn into_inner ( self ) -> T {
144
145
self . 0
145
146
}
146
147
}
147
148
149
+ #[ cfg( feature = "v2" ) ]
148
150
impl < T , ST , DB > Queryable < Nullable < ST > , DB > for RequiredFromNullable < T >
149
151
where
150
152
DB : diesel:: backend:: Backend ,
@@ -165,19 +167,20 @@ pub(crate) mod diesel_impl {
165
167
}
166
168
}
167
169
170
+ #[ cfg( feature = "v2" ) ]
168
171
/// If the DB value is null, this wrapper will provide a default value for the type `T`.
169
172
///
170
173
/// This is useful when you want to ensure that a field is always present, even if the database
171
174
/// value is NULL. The default value is provided by the `Default` trait implementation of `T`.
172
175
pub struct RequiredFromNullableWithDefault < T > ( T ) ;
173
-
176
+ # [ cfg ( feature = "v2" ) ]
174
177
impl < T > RequiredFromNullableWithDefault < T > {
175
178
/// Extracts the inner value from the wrapper
176
179
pub fn into_inner ( self ) -> T {
177
180
self . 0
178
181
}
179
182
}
180
-
183
+ # [ cfg ( feature = "v2" ) ]
181
184
impl < T , ST , DB > Queryable < Nullable < ST > , DB > for RequiredFromNullableWithDefault < T >
182
185
where
183
186
DB : diesel:: backend:: Backend ,
@@ -198,34 +201,54 @@ pub(crate) mod diesel_impl {
198
201
}
199
202
}
200
203
}
201
- }
202
204
203
- /// Macro to implement From trait for types wrapped in RequiredFromNullable
204
- #[ macro_export]
205
- macro_rules! impl_from_required_from_nullable {
206
- ( $( $type: ty) ,* $( , ) ?) => {
207
- $(
208
- impl From <$crate:: RequiredFromNullable <$type>> for $type {
209
- fn from( wrapper: $crate:: RequiredFromNullable <$type>) -> Self {
210
- wrapper. into_inner( )
205
+ #[ cfg( feature = "v2" ) ]
206
+ /// Macro to implement From trait for types wrapped in RequiredFromNullable
207
+ #[ macro_export]
208
+ macro_rules! impl_from_required_from_nullable {
209
+ ( $( $type: ty) ,* $( , ) ?) => {
210
+ $(
211
+ impl From <$crate:: RequiredFromNullable <$type>> for $type {
212
+ fn from( wrapper: $crate:: RequiredFromNullable <$type>) -> Self {
213
+ wrapper. into_inner( )
214
+ }
211
215
}
212
- }
213
- ) *
214
- } ;
215
- }
216
+ ) *
217
+ } ;
218
+ }
216
219
217
- /// Macro to implement From trait for types wrapped in RequiredFromNullableWithDefault
218
- #[ macro_export]
219
- macro_rules! impl_from_required_from_nullable_with_default {
220
- ( $( $type: ty) ,* $( , ) ?) => {
221
- $(
222
- impl From <$crate:: RequiredFromNullableWithDefault <$type>> for $type {
223
- fn from( wrapper: $crate:: RequiredFromNullableWithDefault <$type>) -> Self {
224
- wrapper. into_inner( )
220
+ #[ cfg( feature = "v2" ) ]
221
+ /// Macro to implement From trait for types wrapped in RequiredFromNullableWithDefault
222
+ #[ macro_export]
223
+ macro_rules! impl_from_required_from_nullable_with_default {
224
+ ( $( $type: ty) ,* $( , ) ?) => {
225
+ $(
226
+ impl From <$crate:: RequiredFromNullableWithDefault <$type>> for $type {
227
+ fn from( wrapper: $crate:: RequiredFromNullableWithDefault <$type>) -> Self {
228
+ wrapper. into_inner( )
229
+ }
225
230
}
226
- }
227
- ) *
228
- } ;
231
+ ) *
232
+ } ;
233
+ }
234
+ #[ cfg( feature = "v2" ) ]
235
+ use common_utils:: { id_type, types} ;
236
+
237
+ #[ cfg( feature = "v2" ) ]
238
+ use crate :: enums;
239
+ #[ cfg( feature = "v2" ) ]
240
+ crate :: impl_from_required_from_nullable_with_default!( enums:: DeleteStatus ) ;
241
+
242
+ #[ cfg( feature = "v2" ) ]
243
+ crate :: impl_from_required_from_nullable!(
244
+ enums:: AuthenticationType ,
245
+ types:: MinorUnit ,
246
+ enums:: PaymentMethod ,
247
+ enums:: Currency ,
248
+ id_type:: ProfileId ,
249
+ time:: PrimitiveDateTime ,
250
+ id_type:: RefundReferenceId ,
251
+ ) ;
229
252
}
230
253
231
254
pub ( crate ) mod metrics {
0 commit comments