Skip to content

Commit

Permalink
Fix nullability check for inner joins in postgres (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarPersson authored Jun 1, 2022
1 parent 5d91ffc commit 63291d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions sqlx-core/src/postgres/connection/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,8 @@ fn visit_plan(plan: &Plan, outputs: &[String], nullables: &mut Vec<Option<bool>>
if let Some(plan_outputs) = &plan.output {
// all outputs of a Full Join must be marked nullable
// otherwise, all outputs of the inner half of an outer join must be marked nullable
if let Some("Full") | Some("Inner") = plan
.join_type
.as_deref()
.or(plan.parent_relation.as_deref())
if plan.join_type.as_deref() == Some("Full")
|| plan.parent_relation.as_deref() == Some("Inner")
{
for output in plan_outputs {
if let Some(i) = outputs.iter().position(|o| o == output) {
Expand Down
4 changes: 2 additions & 2 deletions tests/postgres/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,8 @@ async fn test_describe_outer_join_nullable() -> anyhow::Result<()> {
let describe = conn
.describe(
"select tweet.id
from (values (null)) vals(val)
inner join tweet on false",
from tweet
inner join products on products.name = tweet.text",
)
.await?;

Expand Down

0 comments on commit 63291d6

Please sign in to comment.