Skip to content

Commit 5b6cb16

Browse files
author
Curtis McEnroe
committed
Return empty Vec for zero-dimensional array
1 parent e8496a8 commit 5b6cb16

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/types/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,11 @@ impl<T: FromSql> FromSql for Vec<T> {
358358
_ => panic!("expected array type"),
359359
};
360360

361-
if try!(raw.read_i32::<BigEndian>()) != 1 {
362-
return Err(Error::Conversion("array contains too many dimensions".into()));
363-
}
361+
match try!(raw.read_i32::<BigEndian>()) {
362+
0 => return Ok(Vec::new()),
363+
1 => (),
364+
_ => return Err(Error::Conversion("array contains too many dimensions".into())),
365+
};
364366

365367
let _has_nulls = try!(raw.read_i32::<BigEndian>());
366368
let _member_oid = try!(raw.read_u32::<BigEndian>());

0 commit comments

Comments
 (0)