Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8449e4d

Browse files
authored
Merge pull request#1027 from sfackler/oidvector
Fix serialization of oidvector
2 parents8b9b5d0 +e71335e commit8449e4d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

‎postgres-types/src/lib.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,15 @@ impl<'a, T: ToSql> ToSql for &'a [T] {
910910
_ =>panic!("expected array type"),
911911
};
912912

913+
// Arrays are normally one indexed by default but oidvector *requires* zero indexing
914+
let lower_bound =match*ty{
915+
Type::OID_VECTOR =>0,
916+
_ =>1,
917+
};
918+
913919
let dimension =ArrayDimension{
914920
len:downcast(self.len())?,
915-
lower_bound:1,
921+
lower_bound,
916922
};
917923

918924
types::array_to_sql(

‎tokio-postgres/src/connect_socket.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ pub(crate) async fn connect_socket(
1414
host:&Host,
1515
port:u16,
1616
connect_timeout:Option<Duration>,
17-
tcp_user_timeout:Option<Duration>,
17+
#[cfg_attr(not(target_os ="linux"), allow(unused_variables))]tcp_user_timeout:Option<
18+
Duration,
19+
>,
1820
keepalive_config:Option<&KeepaliveConfig>,
1921
) ->Result<Socket,Error>{
2022
match host{

‎tokio-postgres/tests/test/types/mod.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,3 +739,14 @@ async fn ltxtquery_any() {
739739
)
740740
.await;
741741
}
742+
743+
#[tokio::test]
744+
asyncfnoidvector(){
745+
test_type(
746+
"oidvector",
747+
// NB: postgres does not support empty oidarrays! All empty arrays are normalized to zero dimensions, but the
748+
// oidvectorrecv function requires exactly one dimension.
749+
&[(Some(vec![0u32,1,2]),"ARRAY[0,1,2]"),(None,"NULL")],
750+
)
751+
.await;
752+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp