Browse Source

Merge pull request #3444 from nocodb/enhancement/search-mismatch

enhancement: add try catch for covering search mismatch type
pull/3446/head
navi 2 years ago committed by GitHub
parent
commit
bd78cf91a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts
  2. 12
      packages/nocodb/src/lib/meta/api/dataApis/dataApis.ts
  3. 25
      packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

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

12
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 = [];
let count = 0;
try {
data = await nocoExecute(
requestObj, requestObj,
await baseModel.list(listArgs), await baseModel.list(listArgs),
{}, {},
listArgs listArgs
); );
count = await baseModel.count(listArgs);
const 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,

25
packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts

@ -50,7 +50,11 @@ 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 = [];
let count = 0;
try {
data = await nocoExecute(
await getAst({ await getAst({
query: req.query, query: req.query,
model, model,
@ -60,8 +64,11 @@ export async function dataList(req: Request, res: Response) {
{}, {},
listArgs listArgs
); );
count = await baseModel.count(listArgs);
const 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 = [];
let count = 0;
try {
data = data = await nocoExecute(
requestObj, requestObj,
await baseModel.list(req.query), await baseModel.list(req.query),
{}, {},
req.query req.query
); );
count = await baseModel.count(req.query);
const 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