controlx-io / node-red-contrib-cx-alarm-log

A Node-RED industrial alarm parser for simple HMI applications
Other
2 stars 2 forks source link

problem with Microsoft SQL #2

Open Ko-04 opened 1 month ago

Ko-04 commented 1 month ago

In Node-RED, when creating a database in MSSQL, there is an issue with the reserved keyword DESC. This conflict prevents the saving of the alarm description. What are the options for using MSSQL?

cjochum71 commented 1 month ago

Hello, I have the same problem, the problem also exists with MYSQL. It would be great if you could help us. Greetings, Chris

cjochum71 commented 1 month ago

hi, in the path: /.node-red/node_modules/node-red-contrib-cx-alarm-log/nodes in the file: tools.ts search for desc and replace it with another name. If necessary, restart node-red Then replace desc in all nodes

alex-controlx commented 4 weeks ago

yeah, I didn't know it is a reserved word MySQL. Try this quick workaround:

Screenshot 2024-10-27 at 11 24 20 PM

the MySQL converter function is the following:

renameDescToDescription(msg.payload.toAdd);
renameDescToDescription(msg.payload.toUpdate);

return msg;

function renameDescToDescription(arr) {
    for (const event of arr) {
        if (event.desc != null) {
            event.description = event.desc;
            delete event.desc;
        }
    }
}