@@ -11,9 +11,6 @@ use std::fmt;
1111use chrono:: { naive:: NaiveDateTime , DateTime } ;
1212use serde:: { Deserialize , Serialize } ;
1313
14- #[ cfg( feature = "pg" ) ]
15- use crate :: custom:: SqlTypeCustom ;
16- use crate :: custom:: { SqlValCustom , SqlValRefCustom } ;
1714use crate :: { DataObject , Error :: CannotConvertSqlVal , Result , SqlType } ;
1815
1916#[ derive( Clone , Debug ) ]
@@ -29,6 +26,7 @@ pub enum SqlValRef<'a> {
2926 Json ( serde_json:: Value ) ,
3027 #[ cfg( feature = "datetime" ) ]
3128 Timestamp ( NaiveDateTime ) , // NaiveDateTime is Copy
29+ #[ cfg( feature = "custom-pg" ) ]
3230 Custom ( SqlValRefCustom < ' a > ) ,
3331}
3432impl SqlValRef < ' _ > {
@@ -46,7 +44,7 @@ impl SqlValRef<'_> {
4644 SqlValRef :: Blob ( _) => Some ( SqlType :: Blob ) ,
4745 #[ cfg( feature = "json" ) ]
4846 SqlValRef :: Json ( _) => Some ( SqlType :: Json ) ,
49- #[ cfg( feature = "pg" ) ]
47+ #[ cfg( feature = "custom- pg" ) ]
5048 SqlValRef :: Custom ( c) => match c {
5149 SqlValRefCustom :: PgToSql { ty, .. } => {
5250 Some ( SqlType :: Custom ( SqlTypeCustom :: Pg ( ty. clone ( ) ) ) )
@@ -80,6 +78,7 @@ pub enum SqlVal {
8078 Json ( serde_json:: Value ) ,
8179 #[ cfg( feature = "datetime" ) ]
8280 Timestamp ( NaiveDateTime ) ,
81+ #[ cfg( feature = "custom-pg" ) ]
8382 Custom ( Box < SqlValCustom > ) ,
8483}
8584impl SqlVal {
@@ -165,11 +164,11 @@ impl SqlVal {
165164 SqlVal :: Blob ( _) => Some ( SqlType :: Blob ) ,
166165 #[ cfg( feature = "json" ) ]
167166 SqlVal :: Json ( _) => Some ( SqlType :: Json ) ,
168- #[ cfg( feature = "pg" ) ]
167+ #[ cfg( feature = "custom- pg" ) ]
169168 SqlVal :: Custom ( c) => match c. as_ref ( ) {
170169 SqlValCustom :: Pg { ty, .. } => Some ( SqlType :: Custom ( SqlTypeCustom :: Pg ( ty. clone ( ) ) ) ) ,
171170 } ,
172- #[ cfg( not ( feature = "pg" ) ) ]
171+ #[ cfg( feature = "custom- pg" ) ]
173172 SqlVal :: Custom ( _) => None ,
174173 }
175174 }
@@ -189,6 +188,7 @@ impl fmt::Display for SqlVal {
189188 Json ( val) => f. write_str ( val. as_str ( ) . unwrap ( ) ) ,
190189 #[ cfg( feature = "datetime" ) ]
191190 Timestamp ( val) => val. format ( "%+" ) . fmt ( f) ,
191+ #[ cfg( feature = "custom-pg" ) ]
192192 Custom ( val) => val. fmt ( f) ,
193193 }
194194 }
@@ -255,6 +255,7 @@ impl From<SqlValRef<'_>> for SqlVal {
255255 Json ( v) => SqlVal :: Json ( v) ,
256256 #[ cfg( feature = "datetime" ) ]
257257 Timestamp ( v) => SqlVal :: Timestamp ( v) ,
258+ #[ cfg( feature = "custom-pg" ) ]
258259 Custom ( v) => SqlVal :: Custom ( Box :: new ( v. into ( ) ) ) ,
259260 }
260261 }
@@ -275,6 +276,7 @@ impl<'a> From<&'a SqlVal> for SqlValRef<'a> {
275276 Json ( v) => SqlValRef :: Json ( v. to_owned ( ) ) ,
276277 #[ cfg( feature = "datetime" ) ]
277278 Timestamp ( v) => SqlValRef :: Timestamp ( * v) ,
279+ #[ cfg( feature = "custom-pg" ) ]
278280 Custom ( v) => SqlValRef :: Custom ( v. as_valref ( ) ) ,
279281 }
280282 }
0 commit comments