Skip to content

Commit

Permalink
Merge pull request #1051 from andrewbaxter/patch-1
Browse files Browse the repository at this point in the history
Add to_sql for bytes Cow as well
  • Loading branch information
sfackler authored Jul 20, 2023
2 parents 4f41157 + 34c8dc9 commit d16a9cd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions postgres-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,18 @@ impl<T: ToSql> ToSql for Box<[T]> {
to_sql_checked!();
}

impl<'a> ToSql for Cow<'a, [u8]> {
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
<&[u8] as ToSql>::to_sql(&self.as_ref(), ty, w)
}

fn accepts(ty: &Type) -> bool {
<&[u8] as ToSql>::accepts(ty)
}

to_sql_checked!();
}

impl ToSql for Vec<u8> {
fn to_sql(&self, ty: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
<&[u8] as ToSql>::to_sql(&&**self, ty, w)
Expand Down

0 comments on commit d16a9cd

Please sign in to comment.