fix serialization of oidvector
This commit is contained in:
parent
8b9b5d0388
commit
e71335ee43
@ -910,9 +910,15 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
|
||||
_ => panic!("expected array type"),
|
||||
};
|
||||
|
||||
// Arrays are normally one indexed by default but oidvector *requires* zero indexing
|
||||
let lower_bound = match *ty {
|
||||
Type::OID_VECTOR => 0,
|
||||
_ => 1,
|
||||
};
|
||||
|
||||
let dimension = ArrayDimension {
|
||||
len: downcast(self.len())?,
|
||||
lower_bound: 1,
|
||||
lower_bound,
|
||||
};
|
||||
|
||||
types::array_to_sql(
|
||||
|
@ -14,7 +14,9 @@ pub(crate) async fn connect_socket(
|
||||
host: &Host,
|
||||
port: u16,
|
||||
connect_timeout: Option<Duration>,
|
||||
tcp_user_timeout: Option<Duration>,
|
||||
#[cfg_attr(not(target_os = "linux"), allow(unused_variables))] tcp_user_timeout: Option<
|
||||
Duration,
|
||||
>,
|
||||
keepalive_config: Option<&KeepaliveConfig>,
|
||||
) -> Result<Socket, Error> {
|
||||
match host {
|
||||
|
@ -739,3 +739,14 @@ async fn ltxtquery_any() {
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn oidvector() {
|
||||
test_type(
|
||||
"oidvector",
|
||||
// NB: postgres does not support empty oidarrays! All empty arrays are normalized to zero dimensions, but the
|
||||
// oidvectorrecv function requires exactly one dimension.
|
||||
&[(Some(vec![0u32, 1, 2]), "ARRAY[0,1,2]"), (None, "NULL")],
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user