From 16391f146d6b23ca6fb1bb019b2365a70629b46e Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 13 May 2023 14:25:50 +0200 Subject: [PATCH] refs #5541 Debug fixes, fetch delete id index usage fix --- mylogger.js | 10 ++++++---- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mylogger.js b/mylogger.js index 441fcbe..1129f57 100644 --- a/mylogger.js +++ b/mylogger.js @@ -167,7 +167,9 @@ module.exports = class MyLogger { `SELECT id FROM ${sqlTable} WHERE changedModel = ? AND changedModelId = ? - AND action = 'delete'` + AND action = 'delete' + AND (originFk IS NULL OR originFk = ?) + LIMIT 1` ); logInfo.updateStmt = await db.prepare( `UPDATE ${sqlTable} @@ -542,7 +544,7 @@ module.exports = class MyLogger { if (!changes.length) return; - if (this.debug) + if (this.conf.debug) console.debug('Evt:'.blue, `[${action}]`[actionColor[action]], `${tableName}: ${changes.length} changes`); @@ -644,14 +646,14 @@ module.exports = class MyLogger { : modelId; let deleteRow; - if (this.debug) + if (this.conf.debug) console.debug('Log:'.blue, `[${action}]`[actionColor[action]], `${modelName}: ${modelId}`); try { if (isDelete) { [[deleteRow]] = await logInfo.fetchStmt.execute([ - modelName, modelId + modelName, modelId, originFk ]); if (deleteRow) await logInfo.updateStmt.execute([ diff --git a/package-lock.json b/package-lock.json index 51d424d..cda9814 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mylogger", - "version": "0.1.14", + "version": "0.1.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mylogger", - "version": "0.1.14", + "version": "0.1.15", "license": "GPL-3.0", "dependencies": { "colors": "^1.4.0", diff --git a/package.json b/package.json index 21ff764..e7ae23b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mylogger", - "version": "0.1.14", + "version": "0.1.15", "author": "Verdnatura Levante SL", "description": "MySQL and MariaDB logger using binary log", "license": "GPL-3.0",