refactor(PostgreSQL): preparing code to support triggers

This commit is contained in:
Fabio Di Stasio 2021-04-22 15:15:08 +02:00
parent 1d363f755e
commit 86240fb53c
2 changed files with 13 additions and 5 deletions

View File

@ -16,6 +16,7 @@ module.exports = {
tables: false, tables: false,
views: false, views: false,
triggers: false, triggers: false,
triggerFunctions: false,
routines: false, routines: false,
functions: false, functions: false,
schedulers: false, schedulers: false,
@ -23,6 +24,7 @@ module.exports = {
tableAdd: false, tableAdd: false,
viewAdd: false, viewAdd: false,
triggerAdd: false, triggerAdd: false,
triggerFunctionAdd: false,
routineAdd: false, routineAdd: false,
functionAdd: false, functionAdd: false,
schedulerAdd: false, schedulerAdd: false,
@ -31,6 +33,7 @@ module.exports = {
tableSettings: false, tableSettings: false,
viewSettings: false, viewSettings: false,
triggerSettings: false, triggerSettings: false,
triggerFunctionSettings: false,
routineSettings: false, routineSettings: false,
functionSettings: false, functionSettings: false,
schedulerSettings: false, schedulerSettings: false,
@ -59,6 +62,8 @@ module.exports = {
functionSql: false, functionSql: false,
functionContext: false, functionContext: false,
functionLanguage: false, functionLanguage: false,
triggerMiltipleEvents: false,
triggerUpdateColumns: false,
parametersLength: false, parametersLength: false,
languages: false languages: false
}; };

View File

@ -187,12 +187,14 @@ export class PostgreSQLClient extends AntaresCore {
// TRIGGERS // TRIGGERS
const remappedTriggers = triggersArr.filter(trigger => trigger.Db === db.database).map(trigger => { const remappedTriggers = triggersArr.filter(trigger => trigger.Db === db.database).map(trigger => {
return { return {
name: trigger.trigger_name, name: `${trigger.table_name}.${trigger.trigger_name}`,
orgName: trigger.trigger_name,
timing: trigger.activation, timing: trigger.activation,
definer: trigger.definition, // ??? definer: '',
definition: trigger.definition,
event: trigger.event, event: trigger.event,
table: trigger.table_trigger, table: trigger.table_name,
sqlMode: trigger.sql_mode sqlMode: ''
}; };
}); });
@ -516,7 +518,8 @@ export class PostgreSQLClient extends AntaresCore {
* @memberof PostgreSQLClient * @memberof PostgreSQLClient
*/ */
async dropTrigger (params) { async dropTrigger (params) {
const sql = `DROP TRIGGER \`${params.trigger}\``; const triggerParts = params.trigger.split('.');
const sql = `DROP TRIGGER ${triggerParts[1]} ON ${triggerParts[0]}`;
return await this.raw(sql); return await this.raw(sql);
} }