diff --git a/types/mod.rs b/types/mod.rs index 5d10865a..e9ace91d 100644 --- a/types/mod.rs +++ b/types/mod.rs @@ -436,6 +436,13 @@ to_option_impl!(PgFloat4, f32) to_conversions_impl!(PgFloat8, f64, write_be_f64) to_option_impl!(PgFloat8, f64) +impl ToSql for ~str { + fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { + check_types!(PgVarchar | PgText | PgCharN, ty) + (Text, Some(self.as_bytes().to_owned())) + } +} + impl<'self> ToSql for &'self str { fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { check_types!(PgVarchar | PgText | PgCharN, ty) @@ -446,6 +453,13 @@ impl<'self> ToSql for &'self str { to_option_impl!(PgVarchar | PgText | PgCharN, ~str) to_option_impl!(self, PgVarchar | PgText | PgCharN, &'self str) +impl ToSql for ~[u8] { + fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { + check_types!(PgByteA, ty) + (Binary, Some(self.to_owned())) + } +} + impl<'self> ToSql for &'self [u8] { fn to_sql(&self, ty: PostgresType) -> (Format, Option<~[u8]>) { check_types!(PgByteA, ty)