@@ -705,7 +705,7 @@ impl<'a> FromSql<'a> for SystemTime {
705
705
let epoch = UNIX_EPOCH + Duration :: from_secs ( TIME_SEC_CONVERSION ) ;
706
706
707
707
let negative = time < 0 ;
708
- let time = time. abs ( ) as u64 ;
708
+ let time = time. unsigned_abs ( ) ;
709
709
710
710
let secs = time / USEC_PER_SEC ;
711
711
let nsec = ( time % USEC_PER_SEC ) * NSEC_PER_USEC ;
@@ -759,7 +759,7 @@ pub enum IsNull {
759
759
/// | `f64` | DOUBLE PRECISION |
760
760
/// | `&str`/`String` | VARCHAR, CHAR(n), TEXT, CITEXT, NAME |
761
761
/// | | LTREE, LQUERY, LTXTQUERY |
762
- /// | `&[u8]`/`Vec<u8>` | BYTEA |
762
+ /// | `&[u8]`/`Vec<u8>`/`[u8; N]` | BYTEA |
763
763
/// | `HashMap<String, Option<String>>` | HSTORE |
764
764
/// | `SystemTime` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
765
765
/// | `IpAddr` | INET |
@@ -799,9 +799,9 @@ pub enum IsNull {
799
799
///
800
800
/// # Arrays
801
801
///
802
- /// `ToSql` is implemented for `Vec<T>`, `&[T]`, `Box<[T]>` and `[T; N]` where
803
- /// `T` implements `ToSql`, and corresponds to one-dimensional Postgres arrays
804
- /// with an index offset of 1.
802
+ /// `ToSql` is implemented for `[u8; N]`, ` Vec<T>`, `&[T]`, `Box<[T]>` and `[T; N]`
803
+ /// where `T` implements `ToSql` and `N` is const usize , and corresponds to one-dimensional
804
+ /// Postgres arrays with an index offset of 1.
805
805
///
806
806
/// **Note:** the impl for arrays only exist when the Cargo feature `array-impls`
807
807
/// is enabled.
@@ -920,6 +920,18 @@ impl<'a> ToSql for &'a [u8] {
920
920
to_sql_checked ! ( ) ;
921
921
}
922
922
923
+ #[ cfg( feature = "array-impls" ) ]
924
+ impl < const N : usize > ToSql for [ u8 ; N ] {
925
+ fn to_sql ( & self , _: & Type , w : & mut BytesMut ) -> Result < IsNull , Box < dyn Error + Sync + Send > > {
926
+ types:: bytea_to_sql ( & self [ ..] , w) ;
927
+ Ok ( IsNull :: No )
928
+ }
929
+
930
+ accepts ! ( BYTEA ) ;
931
+
932
+ to_sql_checked ! ( ) ;
933
+ }
934
+
923
935
#[ cfg( feature = "array-impls" ) ]
924
936
impl < T : ToSql , const N : usize > ToSql for [ T ; N ] {
925
937
fn to_sql ( & self , ty : & Type , w : & mut BytesMut ) -> Result < IsNull , Box < dyn Error + Sync + Send > > {
0 commit comments