@@ -79,10 +79,7 @@ impl ToSql for PostgresValue {
7979 Value :: String ( v) => v. as_deref ( ) . to_sql ( ty, out) ,
8080 Value :: Char ( v) => v. map ( |v| v. to_string ( ) ) . to_sql ( ty, out) ,
8181 Value :: Bytes ( v) => v. as_deref ( ) . to_sql ( ty, out) ,
82- Value :: Enum ( _) => Err ( PostgresBindError :: new (
83- "Binding Enum is not supported by sea-query-postgres binder" ,
84- )
85- . into ( ) ) ,
82+ Value :: Enum ( v) => v. map ( |v| v. as_str ( ) . to_sql ( ty, out) ) ,
8683 #[ cfg( feature = "with-json" ) ]
8784 Value :: Json ( v) => v. to_sql ( ty, out) ,
8885 #[ cfg( feature = "with-chrono" ) ]
@@ -120,12 +117,14 @@ impl ToSql for PostgresValue {
120117 #[ cfg( feature = "with-bigdecimal" ) ]
121118 Value :: BigDecimal ( v) => {
122119 use bigdecimal:: ToPrimitive ;
123- v. as_ref ( ) . map ( |x| x. to_f64 ( ) . ok_or (
124- PostgresBindError :: new (
125- "Fail to convert bigdecimal as f64 for sea-query-postgres binder" ,
126- )
127- ) ) . transpose ( ) ?. to_sql ( ty, out)
128-
120+ v. as_ref ( )
121+ . map ( |x| {
122+ x. to_f64 ( ) . ok_or ( PostgresBindError :: new (
123+ "Fail to convert bigdecimal as f64 for sea-query-postgres binder" ,
124+ ) )
125+ } )
126+ . transpose ( ) ?
127+ . to_sql ( ty, out)
129128 }
130129 #[ cfg( feature = "with-uuid" ) ]
131130 Value :: Uuid ( v) => v. to_sql ( ty, out) ,
@@ -150,7 +149,7 @@ impl ToSql for PostgresValue {
150149 Array :: BigUnsigned ( inner) => inner
151150 . into_iter ( )
152151 . map ( |v| v. map ( i64:: try_from) . transpose ( ) )
153- . collect :: < Result < Vec < Option < _ > > , _ > > ( ) ?
152+ . collect :: < Result < Vec < Option < _ > > , _ > > ( ) ?
154153 . to_sql ( ty, out) ,
155154 Array :: Float ( inner) => inner. to_sql ( ty, out) ,
156155 Array :: Double ( inner) => inner. to_sql ( ty, out) ,
@@ -235,10 +234,13 @@ impl ToSql for PostgresValue {
235234 "Nested arrays (Array::Array) are not supported by sea-query-postgres binder" ,
236235 )
237236 . into ( ) ) ,
238- Array :: Enum ( _) => Err ( PostgresBindError :: new (
239- "Array of Enum is not supported by sea-query-postgres binder; consider casting in SQL" ,
240- )
241- . into ( ) ) ,
237+ Array :: Enum ( v) => v
238+ . as_ref ( )
239+ . 1
240+ . iter ( )
241+ . map ( |v| v. as_ref ( ) )
242+ . collect :: < Vec < _ > > ( )
243+ . to_sql ( ty, out) ,
242244 _ => Err ( PostgresBindError :: new (
243245 "Unsupported array variant for sea-query-postgres binder" ,
244246 )
0 commit comments