Skip to content

Commit

Permalink
[fix] Make closePool async; Bump nodejs version for mysql test
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Jun 3, 2024
1 parent 8d40162 commit ed74fc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mysqlDatabaseTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Caching dependencies
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '16'
cache: 'npm'
cache-dependency-path: |
./npm-shrinkwrap.json
Expand Down
10 changes: 3 additions & 7 deletions DocService/sources/databaseConnectors/mysqlConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const connectionConfiguration = {
const additionalOptions = configSql.get('mysqlExtraOptions');
const configuration = Object.assign({}, connectionConfiguration, additionalOptions);

let pool = null;
let pool = mysql.createPool(configuration);

function sqlQuery(ctx, sqlCommand, callbackFunction, opt_noModifyRes = false, opt_noLog = false, opt_values = []) {
return executeQuery(ctx, sqlCommand, opt_values, opt_noModifyRes, opt_noLog).then(
Expand All @@ -66,10 +66,6 @@ function sqlQuery(ctx, sqlCommand, callbackFunction, opt_noModifyRes = false, op
async function executeQuery(ctx, sqlCommand, values = [], noModifyRes = false, noLog = false) {
let connection = null;
try {
if (!pool) {
pool = mysql.createPool(configuration);
}

connection = await pool.getConnection();

const result = await connection.query(sqlCommand, values);
Expand Down Expand Up @@ -102,8 +98,8 @@ async function executeQuery(ctx, sqlCommand, values = [], noModifyRes = false, n
}
}

function closePool() {
return pool?.end();
async function closePool() {
return await pool.end();
}

function addSqlParameter(parameter, accumulatedArray) {
Expand Down

0 comments on commit ed74fc4

Please sign in to comment.