@@ -436,6 +436,13 @@ to_option_impl!(PgFloat4, f32)
436436to_conversions_impl ! ( PgFloat8 , f64 , write_be_f64)
437437to_option_impl ! ( PgFloat8 , f64 )
438438
439+ impl ToSql for ~str {
440+ fn to_sql ( & self , ty : PostgresType ) -> ( Format , Option < ~[ u8 ] > ) {
441+ check_types ! ( PgVarchar | PgText | PgCharN , ty)
442+ ( Text , Some ( self . as_bytes ( ) . to_owned ( ) ) )
443+ }
444+ }
445+
439446impl < ' self > ToSql for & ' self str {
440447 fn to_sql ( & self , ty : PostgresType ) -> ( Format , Option < ~[ u8 ] > ) {
441448 check_types ! ( PgVarchar | PgText | PgCharN , ty)
@@ -446,6 +453,13 @@ impl<'self> ToSql for &'self str {
446453to_option_impl ! ( PgVarchar | PgText | PgCharN , ~str )
447454to_option_impl ! ( self , PgVarchar | PgText | PgCharN , & ' self str )
448455
456+ impl ToSql for ~[ u8 ] {
457+ fn to_sql ( & self , ty : PostgresType ) -> ( Format , Option < ~[ u8 ] > ) {
458+ check_types ! ( PgByteA , ty)
459+ ( Binary , Some ( self . to_owned ( ) ) )
460+ }
461+ }
462+
449463impl < ' self > ToSql for & ' self [ u8 ] {
450464 fn to_sql ( & self , ty : PostgresType ) -> ( Format , Option < ~[ u8 ] > ) {
451465 check_types ! ( PgByteA , ty)
0 commit comments