mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +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)) {
|
if (!isEmpty(listRows)) {
|
||||||
const { limit, where_filters: whereFilters, order_filters: orderFilters } = 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 whereQuery = buildPostgrestQuery(whereFilters);
|
||||||
const orderQuery = buildPostgrestQuery(orderFilters);
|
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);
|
!isEmpty(whereQuery) && query.push(whereQuery);
|
||||||
limit && limit !== '' && query.push(`limit=${limit}&order=id`);
|
limit && limit !== '' && query.push(`limit=${limit}&order=id`);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -817,7 +817,7 @@ export function previewQuery(_ref, query, editorState, calledFromQuery = false)
|
||||||
switch (queryStatus) {
|
switch (queryStatus) {
|
||||||
case 'Bad Request':
|
case 'Bad Request':
|
||||||
case 'failed': {
|
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}`);
|
toast.error(`${err.message}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -962,8 +962,8 @@ export function runQuery(_ref, queryId, queryName, confirmed = undefined, mode =
|
||||||
definition: { events: dataQuery.options.events },
|
definition: { events: dataQuery.options.events },
|
||||||
});
|
});
|
||||||
if (mode !== 'view') {
|
if (mode !== 'view') {
|
||||||
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);
|
toast.error(err?.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue