1
1
use crate :: decode:: Decode ;
2
2
use crate :: encode:: { Encode , IsNull } ;
3
3
use crate :: error:: BoxDynError ;
4
- use crate :: postgres:: { PgArgumentBuffer , PgTypeInfo , PgValueFormat , PgValueRef , Postgres } ;
4
+ use crate :: postgres:: {
5
+ PgArgumentBuffer , PgHasArrayType , PgTypeInfo , PgValueFormat , PgValueRef , Postgres ,
6
+ } ;
5
7
use crate :: types:: Type ;
6
8
use chrono:: {
7
9
DateTime , Duration , FixedOffset , Local , NaiveDate , NaiveDateTime , Offset , TimeZone , Utc ,
@@ -20,30 +22,18 @@ impl<Tz: TimeZone> Type<Postgres> for DateTime<Tz> {
20
22
}
21
23
}
22
24
23
- impl Type < Postgres > for [ NaiveDateTime ] {
24
- fn type_info ( ) -> PgTypeInfo {
25
+ impl PgHasArrayType for NaiveDateTime {
26
+ fn array_type_info ( ) -> PgTypeInfo {
25
27
PgTypeInfo :: TIMESTAMP_ARRAY
26
28
}
27
29
}
28
30
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 {
31
33
PgTypeInfo :: TIMESTAMPTZ_ARRAY
32
34
}
33
35
}
34
36
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
-
47
37
impl Encode < ' _ , Postgres > for NaiveDateTime {
48
38
fn encode_by_ref ( & self , buf : & mut PgArgumentBuffer ) -> IsNull {
49
39
// FIXME: We should *really* be returning an error, Encode needs to be fallible
0 commit comments