feat(SQLite): cell update in data tabs

This commit is contained in:
Fabio Di Stasio 2021-11-16 12:56:03 +01:00
parent fd321beece
commit 604b371920
2 changed files with 27 additions and 11 deletions

View File

@ -102,6 +102,9 @@ export default (connections) => {
case 'pg': case 'pg':
escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`; escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`;
break; break;
case 'sqlite':
escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`;
break;
} }
} }
else if (ARRAY.includes(params.type)) else if (ARRAY.includes(params.type))
@ -122,6 +125,10 @@ export default (connections) => {
fileBlob = fs.readFileSync(params.content); fileBlob = fs.readFileSync(params.content);
escapedParam = `decode('${fileBlob.toString('hex')}', 'hex')`; escapedParam = `decode('${fileBlob.toString('hex')}', 'hex')`;
break; break;
case 'sqlite':
fileBlob = fs.readFileSync(params.content);
escapedParam = `X'${fileBlob.toString('hex')}'`;
break;
} }
reload = true; reload = true;
} }
@ -134,6 +141,9 @@ export default (connections) => {
case 'pg': case 'pg':
escapedParam = 'decode(\'\', \'hex\')'; escapedParam = 'decode(\'\', \'hex\')';
break; break;
case 'sqlite':
escapedParam = 'X\'\'';
break;
} }
} }
} }

View File

@ -1276,20 +1276,26 @@ export class SQLiteClient extends AntaresCore {
let fields; let fields;
const detectedTypes = {}; const detectedTypes = {};
const stmt = connection.prepare(query); try {
if (stmt.reader) { const stmt = connection.prepare(query);
queryResult = stmt.all();
fields = stmt.columns();
if (queryResult.length) { if (stmt.reader) {
fields.forEach(field => { queryResult = stmt.all();
detectedTypes[field.name] = typeof queryResult[0][field.name]; 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 { catch (err) {
const info = queryResult = stmt.run(); reject(err);
affectedRows = info.changes;
} }
timeStop = new Date(); timeStop = new Date();