11use crate :: decode:: Decode ;
22use crate :: encode:: { Encode , IsNull } ;
33use crate :: error:: BoxDynError ;
4- use crate :: postgres:: { PgArgumentBuffer , PgTypeInfo , PgValueFormat , PgValueRef , Postgres } ;
4+ use crate :: postgres:: {
5+ PgArgumentBuffer , PgHasArrayType , PgTypeInfo , PgValueFormat , PgValueRef , Postgres ,
6+ } ;
57use crate :: types:: Type ;
68use chrono:: {
79 DateTime , Duration , FixedOffset , Local , NaiveDate , NaiveDateTime , Offset , TimeZone , Utc ,
@@ -20,30 +22,18 @@ impl<Tz: TimeZone> Type<Postgres> for DateTime<Tz> {
2022 }
2123}
2224
23- impl Type < Postgres > for [ NaiveDateTime ] {
24- fn type_info ( ) -> PgTypeInfo {
25+ impl PgHasArrayType for NaiveDateTime {
26+ fn array_type_info ( ) -> PgTypeInfo {
2527 PgTypeInfo :: TIMESTAMP_ARRAY
2628 }
2729}
2830
29- impl < Tz : TimeZone > Type < Postgres > for [ DateTime < Tz > ] {
30- fn type_info ( ) -> PgTypeInfo {
31+ impl < Tz : TimeZone > PgHasArrayType for DateTime < Tz > {
32+ fn array_type_info ( ) -> PgTypeInfo {
3133 PgTypeInfo :: TIMESTAMPTZ_ARRAY
3234 }
3335}
3436
35- impl Type < Postgres > for Vec < NaiveDateTime > {
36- fn type_info ( ) -> PgTypeInfo {
37- <[ NaiveDateTime ] as Type < Postgres > >:: type_info ( )
38- }
39- }
40-
41- impl < Tz : TimeZone > Type < Postgres > for Vec < DateTime < Tz > > {
42- fn type_info ( ) -> PgTypeInfo {
43- <[ DateTime < Tz > ] as Type < Postgres > >:: type_info ( )
44- }
45- }
46-
4737impl Encode < ' _ , Postgres > for NaiveDateTime {
4838 fn encode_by_ref ( & self , buf : & mut PgArgumentBuffer ) -> IsNull {
4939 // FIXME: We should *really* be returning an error, Encode needs to be fallible
0 commit comments