Skip to content

Commit 9daf8b1

Browse files
committed
feat: support [u8; N] as BYTEA
1 parent 0984ab1 commit 9daf8b1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

postgres-types/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,18 @@ impl<'a> ToSql for &'a [u8] {
915915
to_sql_checked!();
916916
}
917917

918+
#[cfg(feature = "array-impls")]
919+
impl<const N: usize> ToSql for [u8; N] {
920+
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
921+
types::bytea_to_sql(&self[..], w);
922+
Ok(IsNull::No)
923+
}
924+
925+
accepts!(BYTEA);
926+
927+
to_sql_checked!();
928+
}
929+
918930
#[cfg(feature = "array-impls")]
919931
impl<T: ToSql, const N: usize> ToSql for [T; N] {
920932
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {

0 commit comments

Comments
 (0)