Skip to content

Commit

Permalink
Add ToSql impls for Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Mar 15, 2014
1 parent 5b646c0 commit c5abe8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::io::{MemWriter, BufReader};
use std::io::util::LimitReader;
use std::str;
use std::vec;
use std::vec_ng::Vec;
use time::Timespec;

use self::array::{Array, ArrayBase, DimensionInfo};
Expand Down Expand Up @@ -543,6 +544,12 @@ impl RawToSql for ~[u8] {
}
}

impl RawToSql for Vec<u8> {
fn raw_to_sql<W: Writer>(&self, w: &mut W) {
or_fail!(w.write(self.as_slice()))
}
}

impl RawToSql for ~str {
fn raw_to_sql<W: Writer>(&self, w: &mut W) {
or_fail!(w.write(self.as_bytes()))
Expand Down Expand Up @@ -677,6 +684,7 @@ macro_rules! to_raw_to_impl(

to_raw_to_impl!(PgBool, bool)
to_raw_to_impl!(PgByteA, ~[u8])
to_raw_to_impl!(PgByteA, Vec<u8>)
to_raw_to_impl!(PgVarchar | PgText | PgCharN, ~str)
to_raw_to_impl!(PgJson, Json)
to_raw_to_impl!(PgChar, i8)
Expand Down Expand Up @@ -749,6 +757,7 @@ macro_rules! to_array_impl(

to_array_impl!(PgBoolArray, bool)
to_array_impl!(PgByteAArray, ~[u8])
to_array_impl!(PgByteAArray, Vec<u8>)
to_array_impl!(PgCharArray, i8)
to_array_impl!(PgInt2Array, i16)
to_array_impl!(PgInt4Array, i32)
Expand Down

0 comments on commit c5abe8c

Please sign in to comment.