Skip to content

Commit 3bb055a

Browse files
committed
Alter [T] ToSql implementation to be one-indexed
This corresponds with the behavior of array literals in Postgres itself. Closes rust-postgres#176
1 parent 92be2db commit 3bb055a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/types/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ pub enum IsNull {
553553
///
554554
/// `ToSql` is implemented for `Vec<T>` and `&[T]` where `T` implements `ToSql`,
555555
/// and corresponds to one-dimentional Postgres arrays with an index offset of
556-
/// 0.
556+
/// 1.
557557
pub trait ToSql: fmt::Debug {
558558
/// Converts the value of `self` into the binary format of the specified
559559
/// Postgres `Type`, writing it to `out`.
@@ -648,7 +648,7 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
648648
try!(w.write_u32::<BigEndian>(member_type.oid()));
649649

650650
try!(w.write_i32::<BigEndian>(try!(downcast(self.len()))));
651-
try!(w.write_i32::<BigEndian>(0)); // index offset
651+
try!(w.write_i32::<BigEndian>(1)); // index offset
652652

653653
let mut inner_buf = vec![];
654654
for e in *self {

0 commit comments

Comments
 (0)