Browse Source

enhancement: add try catch for covering search mismatch type

pull/3444/head
Wing-Kam Wong 2 years ago
parent
commit
a59eb6e072
  1. 2
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts
  2. 22
      packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts
  3. 51
      packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

2
packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

@ -117,7 +117,7 @@ async function getDataList(model, view: View, req) {
listArgs listArgs
); );
count = await baseModel.count(listArgs); count = await baseModel.count(listArgs);
} catch (_) { } catch (e) {
// show empty result instead of throwing error here // show empty result instead of throwing error here
// e.g. search some text in a numeric field // e.g. search some text in a numeric field
} }

22
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); listArgs.sortArr = JSON.parse(listArgs.sortArrJson);
} catch (e) {} } catch (e) {}
const data = await nocoExecute( let data = [];
requestObj, let count = 0;
await baseModel.list(listArgs), try {
{}, data = await nocoExecute(
listArgs requestObj,
); await baseModel.list(listArgs),
{},
const count = await baseModel.count(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, { return new PagedResponseImpl(data, {
count, count,

51
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); listArgs.sortArr = JSON.parse(listArgs.sortArrJson);
} catch (e) {} } catch (e) {}
const data = await nocoExecute( let data = [];
await getAst({ let count = 0;
query: req.query,
model,
view,
}),
await baseModel.list(listArgs),
{},
listArgs
);
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({ res.json({
data: new PagedResponseImpl(data, { ...req.query, count }), data: new PagedResponseImpl(data, { ...req.query, count }),
@ -198,14 +205,20 @@ async function relDataList(req, res) {
extractOnlyPrimaries: true, extractOnlyPrimaries: true,
}); });
const data = await nocoExecute( let data = [];
requestObj, let count = 0;
await baseModel.list(req.query), try {
{}, data = data = await nocoExecute(
req.query requestObj,
); await baseModel.list(req.query),
{},
const count = await baseModel.count(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 })); res.json(new PagedResponseImpl(data, { ...req.query, count }));
} }

Loading…
Cancel
Save