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
);
count = await baseModel.count(listArgs);
} catch (_) {
} catch (e) {
// show empty result instead of throwing error here
// 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);
} 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,

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);
} 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 }));
}

Loading…
Cancel
Save