Fix int2vector serialization

This commit is contained in:
Steven Fackler 2023-05-01 19:45:54 -04:00
parent 8449e4d9ea
commit d92b3b0a63
No known key found for this signature in database
GPG Key ID: 408917B7276A5226
2 changed files with 13 additions and 2 deletions

View File

@ -910,9 +910,9 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
_ => panic!("expected array type"),
};
// Arrays are normally one indexed by default but oidvector *requires* zero indexing
// Arrays are normally one indexed by default but oidvector and int2vector *require* zero indexing
let lower_bound = match *ty {
Type::OID_VECTOR => 0,
Type::OID_VECTOR | Type::INT2_VECTOR => 0,
_ => 1,
};

View File

@ -750,3 +750,14 @@ async fn oidvector() {
)
.await;
}
#[tokio::test]
async fn int2vector() {
test_type(
"int2vector",
// NB: postgres does not support empty int2vectors! All empty arrays are normalized to zero dimensions, but the
// oidvectorrecv function requires exactly one dimension.
&[(Some(vec![0i16, 1, 2]), "ARRAY[0,1,2]"), (None, "NULL")],
)
.await;
}