@@ -11,8 +11,9 @@ use std::fmt;
11
11
use chrono:: { naive:: NaiveDateTime , DateTime } ;
12
12
use serde:: { Deserialize , Serialize } ;
13
13
14
- #[ cfg( feature = "pg" ) ]
14
+ #[ cfg( feature = "custom- pg" ) ]
15
15
use crate :: custom:: SqlTypeCustom ;
16
+ #[ cfg( feature = "custom-pg" ) ]
16
17
use crate :: custom:: { SqlValCustom , SqlValRefCustom } ;
17
18
use crate :: { DataObject , Error :: CannotConvertSqlVal , Result , SqlType } ;
18
19
@@ -29,6 +30,7 @@ pub enum SqlValRef<'a> {
29
30
Json ( serde_json:: Value ) ,
30
31
#[ cfg( feature = "datetime" ) ]
31
32
Timestamp ( NaiveDateTime ) , // NaiveDateTime is Copy
33
+ #[ cfg( feature = "custom-pg" ) ]
32
34
Custom ( SqlValRefCustom < ' a > ) ,
33
35
}
34
36
impl SqlValRef < ' _ > {
@@ -46,7 +48,7 @@ impl SqlValRef<'_> {
46
48
SqlValRef :: Blob ( _) => Some ( SqlType :: Blob ) ,
47
49
#[ cfg( feature = "json" ) ]
48
50
SqlValRef :: Json ( _) => Some ( SqlType :: Json ) ,
49
- #[ cfg( feature = "pg" ) ]
51
+ #[ cfg( feature = "custom- pg" ) ]
50
52
SqlValRef :: Custom ( c) => match c {
51
53
SqlValRefCustom :: PgToSql { ty, .. } => {
52
54
Some ( SqlType :: Custom ( SqlTypeCustom :: Pg ( ty. clone ( ) ) ) )
@@ -55,8 +57,6 @@ impl SqlValRef<'_> {
55
57
Some ( SqlType :: Custom ( SqlTypeCustom :: Pg ( ty. clone ( ) ) ) )
56
58
}
57
59
} ,
58
- #[ cfg( not( feature = "pg" ) ) ]
59
- SqlValRef :: Custom ( _) => None ,
60
60
}
61
61
}
62
62
}
@@ -80,6 +80,7 @@ pub enum SqlVal {
80
80
Json ( serde_json:: Value ) ,
81
81
#[ cfg( feature = "datetime" ) ]
82
82
Timestamp ( NaiveDateTime ) ,
83
+ #[ cfg( feature = "custom-pg" ) ]
83
84
Custom ( Box < SqlValCustom > ) ,
84
85
}
85
86
impl SqlVal {
@@ -165,11 +166,11 @@ impl SqlVal {
165
166
SqlVal :: Blob ( _) => Some ( SqlType :: Blob ) ,
166
167
#[ cfg( feature = "json" ) ]
167
168
SqlVal :: Json ( _) => Some ( SqlType :: Json ) ,
168
- #[ cfg( feature = "pg" ) ]
169
+ #[ cfg( feature = "custom- pg" ) ]
169
170
SqlVal :: Custom ( c) => match c. as_ref ( ) {
170
171
SqlValCustom :: Pg { ty, .. } => Some ( SqlType :: Custom ( SqlTypeCustom :: Pg ( ty. clone ( ) ) ) ) ,
171
172
} ,
172
- #[ cfg( not ( feature = "pg" ) ) ]
173
+ #[ cfg( feature = "custom- pg" ) ]
173
174
SqlVal :: Custom ( _) => None ,
174
175
}
175
176
}
@@ -189,6 +190,7 @@ impl fmt::Display for SqlVal {
189
190
Json ( val) => f. write_str ( val. as_str ( ) . unwrap ( ) ) ,
190
191
#[ cfg( feature = "datetime" ) ]
191
192
Timestamp ( val) => val. format ( "%+" ) . fmt ( f) ,
193
+ #[ cfg( feature = "custom-pg" ) ]
192
194
Custom ( val) => val. fmt ( f) ,
193
195
}
194
196
}
@@ -255,6 +257,7 @@ impl From<SqlValRef<'_>> for SqlVal {
255
257
Json ( v) => SqlVal :: Json ( v) ,
256
258
#[ cfg( feature = "datetime" ) ]
257
259
Timestamp ( v) => SqlVal :: Timestamp ( v) ,
260
+ #[ cfg( feature = "custom-pg" ) ]
258
261
Custom ( v) => SqlVal :: Custom ( Box :: new ( v. into ( ) ) ) ,
259
262
}
260
263
}
@@ -275,6 +278,7 @@ impl<'a> From<&'a SqlVal> for SqlValRef<'a> {
275
278
Json ( v) => SqlValRef :: Json ( v. to_owned ( ) ) ,
276
279
#[ cfg( feature = "datetime" ) ]
277
280
Timestamp ( v) => SqlValRef :: Timestamp ( * v) ,
281
+ #[ cfg( feature = "custom-pg" ) ]
278
282
Custom ( v) => SqlValRef :: Custom ( v. as_valref ( ) ) ,
279
283
}
280
284
}
0 commit comments