Skip to content

Commit 936744d

Browse files
jwangnzabonander
andauthored
Fix describe on PostgreSQL views with rules (#2736)
* fix postgres describe on multiple explains * inline the first explain using smallvec * fix: regenerate `Cargo.lock` --------- Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
1 parent 4c68302 commit 936744d

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

Cargo.lock

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqlx-postgres/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ log = "0.4.17"
5757
memchr = { version = "2.4.1", default-features = false }
5858
num-bigint = { version = "0.4.3", optional = true }
5959
once_cell = "1.9.0"
60-
smallvec = "1.7.0"
60+
smallvec = { version = "1.7.0", features = ["serde"] }
6161
stringprep = "0.1.2"
6262
thiserror = "1.0.35"
6363
tracing = { version = "0.1.37", features = ["log"] }

sqlx-postgres/src/connection/describe.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::types::Oid;
1010
use crate::HashMap;
1111
use crate::{PgArguments, PgColumn, PgConnection, PgTypeInfo};
1212
use futures_core::future::BoxFuture;
13+
use smallvec::SmallVec;
1314
use std::fmt::Write;
1415
use std::sync::Arc;
1516

@@ -447,20 +448,21 @@ WHERE rngtypid = $1
447448
explain += ")";
448449
}
449450

450-
let (Json([explain]),): (Json<[Explain; 1]>,) = query_as(&explain).fetch_one(self).await?;
451+
let (Json(explains),): (Json<SmallVec<[Explain; 1]>>,) =
452+
query_as(&explain).fetch_one(self).await?;
451453

452454
let mut nullables = Vec::new();
453455

454-
if let Explain::Plan {
456+
if let Some(Explain::Plan {
455457
plan:
456458
plan @ Plan {
457459
output: Some(ref outputs),
458460
..
459461
},
460-
} = &explain
462+
}) = explains.first()
461463
{
462464
nullables.resize(outputs.len(), None);
463-
visit_plan(plan, outputs, &mut nullables);
465+
visit_plan(&plan, outputs, &mut nullables);
464466
}
465467

466468
Ok(nullables)

0 commit comments

Comments
 (0)