mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:26:22 +00:00
chore: show constraints query path
This commit is contained in:
parent
f82be2a207
commit
408383becf
@ -89,13 +89,7 @@ export function patchSequelizeQueryInterface(db: Database) {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const queryGenerator = db.sequelize.dialect.queryGenerator;
|
const queryGenerator = db.sequelize.dialect.queryGenerator;
|
||||||
|
|
||||||
const originalShowConstraintsQuery = queryGenerator.showConstraintsQuery;
|
|
||||||
|
|
||||||
queryGenerator.showConstraintsQuery = (tableName, constraintName) => {
|
queryGenerator.showConstraintsQuery = (tableName, constraintName) => {
|
||||||
if (!constraintName) {
|
|
||||||
return originalShowConstraintsQuery.call(queryGenerator, tableName, constraintName);
|
|
||||||
}
|
|
||||||
|
|
||||||
const lines = [
|
const lines = [
|
||||||
'SELECT constraint_catalog AS "constraintCatalog",',
|
'SELECT constraint_catalog AS "constraintCatalog",',
|
||||||
'constraint_schema AS "constraintSchema",',
|
'constraint_schema AS "constraintSchema",',
|
||||||
@ -108,9 +102,12 @@ export function patchSequelizeQueryInterface(db: Database) {
|
|||||||
'initially_deferred AS "initiallyDeferred"',
|
'initially_deferred AS "initiallyDeferred"',
|
||||||
'from INFORMATION_SCHEMA.table_constraints',
|
'from INFORMATION_SCHEMA.table_constraints',
|
||||||
`WHERE table_name='${tableName}'`,
|
`WHERE table_name='${tableName}'`,
|
||||||
`AND constraint_name='${constraintName}'`,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (!constraintName) {
|
||||||
|
lines.push(`AND constraint_name='${constraintName}'`);
|
||||||
|
}
|
||||||
|
|
||||||
if (db.options.schema && db.options.schema !== 'public') {
|
if (db.options.schema && db.options.schema !== 'public') {
|
||||||
lines.push(`AND table_schema='${db.options.schema}'`);
|
lines.push(`AND table_schema='${db.options.schema}'`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user