From 00429f3bdbfe56af1afcee94b069a9619cea4263 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 12 May 2022 22:21:27 +0800 Subject: [PATCH] PostgreSQL query non-key foreign key info (#65) --- src/postgres/query/constraints/mod.rs | 10 +++++----- src/postgres/query/schema.rs | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/postgres/query/constraints/mod.rs b/src/postgres/query/constraints/mod.rs index b4666513..f08dd4ad 100644 --- a/src/postgres/query/constraints/mod.rs +++ b/src/postgres/query/constraints/mod.rs @@ -144,14 +144,14 @@ impl SchemaQueryBuilder { (Schema::ReferentialConstraints, RefC::DeleteRule), ]) .columns(vec![ - (Schema::KeyColumnUsage, Kcuf::TableName), - (Schema::KeyColumnUsage, Kcuf::ColumnName), + (Schema::ConstraintColumnUsage, Kcuf::TableName), + (Schema::ConstraintColumnUsage, Kcuf::ColumnName), ]) .from((Schema::Schema, Schema::ReferentialConstraints)) .left_join( - (Schema::Schema, Schema::KeyColumnUsage), - Expr::tbl(Schema::ReferentialConstraints, RefC::UniqueConstraintName) - .equals(Schema::KeyColumnUsage, Kcuf::ConstraintName), + (Schema::Schema, Schema::ConstraintColumnUsage), + Expr::tbl(Schema::ReferentialConstraints, RefC::ConstraintName) + .equals(Schema::ConstraintColumnUsage, Kcuf::ConstraintName), ) .take(), rcsq.clone(), diff --git a/src/postgres/query/schema.rs b/src/postgres/query/schema.rs index f15751a8..96469cbf 100644 --- a/src/postgres/query/schema.rs +++ b/src/postgres/query/schema.rs @@ -12,4 +12,5 @@ pub enum InformationSchema { ReferentialConstraints, Tables, TableConstraints, + ConstraintColumnUsage, }