From 408383becf579eea634534d99018c6efa68bad4e Mon Sep 17 00:00:00 2001 From: Chareice Date: Tue, 14 Feb 2023 21:36:42 +0800 Subject: [PATCH] chore: show constraints query path --- packages/core/database/src/utils.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/core/database/src/utils.ts b/packages/core/database/src/utils.ts index bbe041c30..c11c98cf3 100644 --- a/packages/core/database/src/utils.ts +++ b/packages/core/database/src/utils.ts @@ -89,13 +89,7 @@ export function patchSequelizeQueryInterface(db: Database) { //@ts-ignore const queryGenerator = db.sequelize.dialect.queryGenerator; - const originalShowConstraintsQuery = queryGenerator.showConstraintsQuery; - queryGenerator.showConstraintsQuery = (tableName, constraintName) => { - if (!constraintName) { - return originalShowConstraintsQuery.call(queryGenerator, tableName, constraintName); - } - const lines = [ 'SELECT constraint_catalog AS "constraintCatalog",', 'constraint_schema AS "constraintSchema",', @@ -108,9 +102,12 @@ export function patchSequelizeQueryInterface(db: Database) { 'initially_deferred AS "initiallyDeferred"', 'from INFORMATION_SCHEMA.table_constraints', `WHERE table_name='${tableName}'`, - `AND constraint_name='${constraintName}'`, ]; + if (!constraintName) { + lines.push(`AND constraint_name='${constraintName}'`); + } + if (db.options.schema && db.options.schema !== 'public') { lines.push(`AND table_schema='${db.options.schema}'`); }