fix: deletion of rows from query results

This commit is contained in:
Fabio Di Stasio 2021-04-08 21:49:38 +02:00
parent 9f5ec0276c
commit c20bff7bcb
2 changed files with 9 additions and 5 deletions

View File

@ -157,9 +157,13 @@ export default (connections) => {
ipcMain.handle('delete-table-rows', async (event, params) => { ipcMain.handle('delete-table-rows', async (event, params) => {
if (params.primary) { if (params.primary) {
const idString = params.rows.map(row => typeof row[params.primary] === 'string' const idString = params.rows.map(row => {
? `"${row[params.primary]}"` const fieldName = Object.keys(row)[0].includes('.') ? `${params.table}.${params.primary}` : params.primary;
: row[params.primary]).join(',');
return typeof row[fieldName] === 'string'
? `"${row[fieldName]}"`
: row[fieldName];
}).join(',');
try { try {
const result = await connections[params.uid] const result = await connections[params.uid]

View File

@ -42,6 +42,7 @@ export default {
try { try {
const { status, response } = await Tables.deleteTableRows(params); const { status, response } = await Tables.deleteTableRows(params);
this.isQuering = false;
if (status === 'success') if (status === 'success')
this.reloadTable(); this.reloadTable();
@ -50,9 +51,8 @@ export default {
} }
catch (err) { catch (err) {
this.addNotification({ status: 'error', message: err.stack }); this.addNotification({ status: 'error', message: err.stack });
}
this.isQuering = false; this.isQuering = false;
} }
} }
}
}; };