refs #5541 Debug fixes, fetch delete id index usage fix
gitea/mylogger/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2023-05-13 14:25:50 +02:00
parent 810fb55416
commit 16391f146d
3 changed files with 9 additions and 7 deletions

View File

@ -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([

4
package-lock.json generated
View File

@ -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",

View File

@ -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",