Merge pull request #1027 from sfackler/oidvector
Fix serialization of oidvector
This commit is contained in:
commit
8449e4d9ea
@ -910,9 +910,15 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
|
|||||||
_ => panic!("expected array type"),
|
_ => 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 {
|
let dimension = ArrayDimension {
|
||||||
len: downcast(self.len())?,
|
len: downcast(self.len())?,
|
||||||
lower_bound: 1,
|
lower_bound,
|
||||||
};
|
};
|
||||||
|
|
||||||
types::array_to_sql(
|
types::array_to_sql(
|
||||||
|
@ -14,7 +14,9 @@ pub(crate) async fn connect_socket(
|
|||||||
host: &Host,
|
host: &Host,
|
||||||
port: u16,
|
port: u16,
|
||||||
connect_timeout: Option<Duration>,
|
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>,
|
keepalive_config: Option<&KeepaliveConfig>,
|
||||||
) -> Result<Socket, Error> {
|
) -> Result<Socket, Error> {
|
||||||
match host {
|
match host {
|
||||||
|
@ -739,3 +739,14 @@ async fn ltxtquery_any() {
|
|||||||
)
|
)
|
||||||
.await;
|
.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