@@ -705,7 +705,7 @@ impl<'a> FromSql<'a> for SystemTime {
705705 let epoch = UNIX_EPOCH + Duration :: from_secs ( TIME_SEC_CONVERSION ) ;
706706
707707 let negative = time < 0 ;
708- let time = time. abs ( ) as u64 ;
708+ let time = time. unsigned_abs ( ) ;
709709
710710 let secs = time / USEC_PER_SEC ;
711711 let nsec = ( time % USEC_PER_SEC ) * NSEC_PER_USEC ;
@@ -759,7 +759,7 @@ pub enum IsNull {
759759/// | `f64` | DOUBLE PRECISION |
760760/// | `&str`/`String` | VARCHAR, CHAR(n), TEXT, CITEXT, NAME |
761761/// | | LTREE, LQUERY, LTXTQUERY |
762- /// | `&[u8]`/`Vec<u8>` | BYTEA |
762+ /// | `&[u8]`/`Vec<u8>`/`[u8; N]` | BYTEA |
763763/// | `HashMap<String, Option<String>>` | HSTORE |
764764/// | `SystemTime` | TIMESTAMP, TIMESTAMP WITH TIME ZONE |
765765/// | `IpAddr` | INET |
@@ -799,9 +799,9 @@ pub enum IsNull {
799799///
800800/// # Arrays
801801///
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.
805805///
806806/// **Note:** the impl for arrays only exist when the Cargo feature `array-impls`
807807/// is enabled.
@@ -920,6 +920,18 @@ impl<'a> ToSql for &'a [u8] {
920920 to_sql_checked ! ( ) ;
921921}
922922
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+
923935#[ cfg( feature = "array-impls" ) ]
924936impl < T : ToSql , const N : usize > ToSql for [ T ; N ] {
925937 fn to_sql ( & self , ty : & Type , w : & mut BytesMut ) -> Result < IsNull , Box < dyn Error + Sync + Send > > {
0 commit comments