Alter [T] ToSql implementation to be one-indexed

This corresponds with the behavior of array literals in Postgres itself.

Closes #176
This commit is contained in:
Steven Fackler
2016-05-01 23:06:57 -07:00
parent 92be2db0e2
commit 3bb055ad98

View File

@@ -553,7 +553,7 @@ pub enum IsNull {
///
/// `ToSql` is implemented for `Vec<T>` and `&[T]` where `T` implements `ToSql`,
/// and corresponds to one-dimentional Postgres arrays with an index offset of
/// 0.
/// 1.
pub trait ToSql: fmt::Debug {
/// Converts the value of `self` into the binary format of the specified
/// Postgres `Type`, writing it to `out`.
@@ -648,7 +648,7 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
try!(w.write_u32::<BigEndian>(member_type.oid()));
try!(w.write_i32::<BigEndian>(try!(downcast(self.len()))));
try!(w.write_i32::<BigEndian>(0)); // index offset
try!(w.write_i32::<BigEndian>(1)); // index offset
let mut inner_buf = vec![];
for e in *self {