diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts index b982bbc4de..46e7e071ae 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts @@ -107,14 +107,20 @@ async function getDataList(model, view: View, req) { listArgs.sortArr = JSON.parse(listArgs.sortArrJson); } catch (e) {} - const data = await nocoExecute( - requestObj, - await baseModel.list(listArgs), - {}, - listArgs - ); - - const count = await baseModel.count(listArgs); + let data = []; + let count = 0; + try { + data = await nocoExecute( + requestObj, + await baseModel.list(listArgs), + {}, + listArgs + ); + count = await baseModel.count(listArgs); + } catch (e) { + // show empty result instead of throwing error here + // e.g. search some text in a numeric field + } return new PagedResponseImpl(data, { ...req.query, diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts index c142ae4303..2635478eaa 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts @@ -452,14 +452,20 @@ async function getDataList(model, view: View, req) { listArgs.sortArr = JSON.parse(listArgs.sortArrJson); } catch (e) {} - const data = await nocoExecute( - requestObj, - await baseModel.list(listArgs), - {}, - listArgs - ); - - const count = await baseModel.count(listArgs); + let data = []; + let count = 0; + try { + data = await nocoExecute( + requestObj, + await baseModel.list(listArgs), + {}, + listArgs + ); + count = await baseModel.count(listArgs); + } catch (e) { + // show empty result instead of throwing error here + // e.g. search some text in a numeric field + } return new PagedResponseImpl(data, { count, diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts index 345bc5e3b8..fb904c6a1c 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts @@ -50,18 +50,25 @@ export async function dataList(req: Request, res: Response) { listArgs.sortArr = JSON.parse(listArgs.sortArrJson); } catch (e) {} - const data = await nocoExecute( - await getAst({ - query: req.query, - model, - view, - }), - await baseModel.list(listArgs), - {}, - listArgs - ); + let data = []; + let count = 0; - const count = await baseModel.count(listArgs); + try { + data = await nocoExecute( + await getAst({ + query: req.query, + model, + view, + }), + await baseModel.list(listArgs), + {}, + listArgs + ); + count = await baseModel.count(listArgs); + } catch (e) { + // show empty result instead of throwing error here + // e.g. search some text in a numeric field + } res.json({ data: new PagedResponseImpl(data, { ...req.query, count }), @@ -198,14 +205,20 @@ async function relDataList(req, res) { extractOnlyPrimaries: true, }); - const data = await nocoExecute( - requestObj, - await baseModel.list(req.query), - {}, - req.query - ); - - const count = await baseModel.count(req.query); + let data = []; + let count = 0; + try { + data = data = await nocoExecute( + requestObj, + await baseModel.list(req.query), + {}, + req.query + ); + count = await baseModel.count(req.query); + } catch (e) { + // show empty result instead of throwing error here + // e.g. search some text in a numeric field + } res.json(new PagedResponseImpl(data, { ...req.query, count })); }