mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
[Bugfix] app crashes when delete op is ran for tj db query (#5342)
* fixes: app crashes when delete op is ran for tj db query * fixe: error toast for preview query: tj-db * fixes:Validation of Limit input field
This commit is contained in:
parent
15bd45c2d2
commit
be3fc4b9bb
2 changed files with 24 additions and 3 deletions
|
|
@ -59,6 +59,17 @@ async function listRows(queryOptions, organizationId, currentState) {
|
|||
|
||||
if (!isEmpty(listRows)) {
|
||||
const { limit, where_filters: whereFilters, order_filters: orderFilters } = listRows;
|
||||
|
||||
if (limit && isNaN(limit)) {
|
||||
return {
|
||||
status: 'failed',
|
||||
statusText: 'failed',
|
||||
message: 'Please provide a valid limit',
|
||||
description: 'Limit should be a number',
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
const whereQuery = buildPostgrestQuery(whereFilters);
|
||||
const orderQuery = buildPostgrestQuery(orderFilters);
|
||||
|
||||
|
|
@ -113,6 +124,16 @@ async function deleteRows(queryOptions, organizationId, currentState) {
|
|||
};
|
||||
}
|
||||
|
||||
if (limit && isNaN(limit)) {
|
||||
return {
|
||||
status: 'failed',
|
||||
statusText: 'failed',
|
||||
message: 'Please provide a valid limit',
|
||||
description: 'Limit should be a number',
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
!isEmpty(whereQuery) && query.push(whereQuery);
|
||||
limit && limit !== '' && query.push(`limit=${limit}&order=id`);
|
||||
|
||||
|
|
|
|||
|
|
@ -817,7 +817,7 @@ export function previewQuery(_ref, query, editorState, calledFromQuery = false)
|
|||
switch (queryStatus) {
|
||||
case 'Bad Request':
|
||||
case 'failed': {
|
||||
const err = query.kind == 'tooljetdb' ? data.error : _.isEmpty(data.data) ? data : data.data;
|
||||
const err = query.kind == 'tooljetdb' ? data?.error || data : _.isEmpty(data.data) ? data : data.data;
|
||||
toast.error(`${err.message}`);
|
||||
break;
|
||||
}
|
||||
|
|
@ -962,8 +962,8 @@ export function runQuery(_ref, queryId, queryName, confirmed = undefined, mode =
|
|||
definition: { events: dataQuery.options.events },
|
||||
});
|
||||
if (mode !== 'view') {
|
||||
const err = query.kind == 'tooljetdb' ? data.error : _.isEmpty(data.data) ? data : data.data;
|
||||
toast.error(err.message);
|
||||
const err = query.kind == 'tooljetdb' ? data?.error || data : _.isEmpty(data.data) ? data : data.data;
|
||||
toast.error(err?.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue