diff --git a/src/main/ipc-handlers/tables.js b/src/main/ipc-handlers/tables.js index 997dadb0..e0faf307 100644 --- a/src/main/ipc-handlers/tables.js +++ b/src/main/ipc-handlers/tables.js @@ -102,6 +102,9 @@ export default (connections) => { case 'pg': escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`; break; + case 'sqlite': + escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`; + break; } } else if (ARRAY.includes(params.type)) @@ -122,6 +125,10 @@ export default (connections) => { fileBlob = fs.readFileSync(params.content); escapedParam = `decode('${fileBlob.toString('hex')}', 'hex')`; break; + case 'sqlite': + fileBlob = fs.readFileSync(params.content); + escapedParam = `X'${fileBlob.toString('hex')}'`; + break; } reload = true; } @@ -134,6 +141,9 @@ export default (connections) => { case 'pg': escapedParam = 'decode(\'\', \'hex\')'; break; + case 'sqlite': + escapedParam = 'X\'\''; + break; } } } diff --git a/src/main/libs/clients/SQLiteClient.js b/src/main/libs/clients/SQLiteClient.js index 1283a673..44fd15f8 100644 --- a/src/main/libs/clients/SQLiteClient.js +++ b/src/main/libs/clients/SQLiteClient.js @@ -1276,20 +1276,26 @@ export class SQLiteClient extends AntaresCore { let fields; const detectedTypes = {}; - const stmt = connection.prepare(query); - if (stmt.reader) { - queryResult = stmt.all(); - fields = stmt.columns(); + try { + const stmt = connection.prepare(query); - if (queryResult.length) { - fields.forEach(field => { - detectedTypes[field.name] = typeof queryResult[0][field.name]; - }); + if (stmt.reader) { + queryResult = stmt.all(); + fields = stmt.columns(); + + if (queryResult.length) { + fields.forEach(field => { + detectedTypes[field.name] = typeof queryResult[0][field.name]; + }); + } + } + else { + const info = queryResult = stmt.run(); + affectedRows = info.changes; } } - else { - const info = queryResult = stmt.run(); - affectedRows = info.changes; + catch (err) { + reject(err); } timeStop = new Date();