From 64496e4a97541c4cb3c9bdeb3eaf677843ced1ec Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:55:56 +0200 Subject: [PATCH 1/2] Return filled in SQL in query result queryAsString now uses the statement with its values substituted which the ILG status bar displays. --- InfoLogger/lib/services/QueryService.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/InfoLogger/lib/services/QueryService.js b/InfoLogger/lib/services/QueryService.js index 4d31d336e..2182bc124 100644 --- a/InfoLogger/lib/services/QueryService.js +++ b/InfoLogger/lib/services/QueryService.js @@ -102,9 +102,10 @@ class QueryService { const criteriaString = this._getCriteriaAsString(criteria); const requestRows = `SELECT * FROM \`messages\` ${criteriaString} ORDER BY \`TIMESTAMP\` LIMIT ?;`; const queryValues = [...values, limit]; + const queryAsString = processPreparedSQLStatement(requestRows, values, limit); const startTime = Date.now(); // ms - this._logger.debugMessage(`SQL to execute: ${processPreparedSQLStatement(requestRows, values, limit)}`); + this._logger.debugMessage(`SQL to execute: ${queryAsString}`); let rows = []; let connection = null; @@ -144,7 +145,7 @@ class QueryService { count: rows.length, limit: limit, time: totalTime, // ms - queryAsString: this._getSQLQueryAsString(criteriaString, limit), + queryAsString, }; } @@ -186,16 +187,6 @@ class QueryService { return criteria && criteria.length ? `WHERE ${criteria.join(' AND ')}` : ''; } - /** - * Get the SQL Query used as a string - * @param {string} criteriaVerbose - criteria as string in SQL format - * @param {number} limit - limit of number of messages - * @returns {string} - SQL Query as string - */ - _getSQLQueryAsString(criteriaVerbose, limit) { - return `SELECT * FROM \`messages\` ${criteriaVerbose} ORDER BY \`TIMESTAMP\` LIMIT ${limit}`; - } - /** * Translates `filters` from client side to SQL condition to put on WHERE clause * From b2845f9a7cb3a2f5d4bba59778930e333d0e716b Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:56:08 +0200 Subject: [PATCH 2/2] Adjust test --- InfoLogger/test/lib/services/mocha-query-service.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/InfoLogger/test/lib/services/mocha-query-service.test.js b/InfoLogger/test/lib/services/mocha-query-service.test.js index b5a017b01..1be3a2f85 100644 --- a/InfoLogger/test/lib/services/mocha-query-service.test.js +++ b/InfoLogger/test/lib/services/mocha-query-service.test.js @@ -329,8 +329,9 @@ describe('\'QueryService\' test suite', () => { }); it('should successfully return result when filters are provided for querying', async () => { - const query = 'SELECT * FROM `messages` WHERE `timestamp`>=? AND `timestamp`<=? AND `hostname` = ? ' - + 'AND NOT(`hostname` = ? AND `hostname` IS NOT NULL) AND `severity` IN (?) ORDER BY `TIMESTAMP` LIMIT 10'; + const query = 'SELECT * FROM `messages` WHERE `timestamp`>=\'1563794601.351\' AND `timestamp`<=\'1563794661.354\' ' + + 'AND `hostname` = \'test\' AND NOT(`hostname` = \'testEx\' AND `hostname` IS NOT NULL) ' + + 'AND `severity` IN (\'D\',\'W\') ORDER BY `TIMESTAMP` LIMIT 10;'; const sqlDataSource = new QueryService(); const connection = {