Browse Source

fix(nocodb): use dependencyFields from AST instead of param.query

pull/5490/head
Wing-Kam Wong 2 years ago
parent
commit
7ca9c59618
  1. 20
      packages/nocodb/src/lib/services/public/publicData.svc.ts

20
packages/nocodb/src/lib/services/public/publicData.svc.ts

@ -69,10 +69,7 @@ export async function dataList(param: {
count = await baseModel.count(listArgs); count = await baseModel.count(listArgs);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
// show empty result instead of throwing error here NcError.internalServerError('Please check server log for more details');
// e.g. search some text in a numeric field
NcError.internalServerError('Please try after some time');
} }
return new PagedResponseImpl(data, { ...param.query, count }); return new PagedResponseImpl(data, { ...param.query, count });
@ -294,6 +291,7 @@ export async function relDataList(param: {
} }
const column = await Column.get({ colId: param.columnId }); const column = await Column.get({ colId: param.columnId });
const colOptions = await column.getColOptions<LinkToAnotherRecordColumn>(); const colOptions = await column.getColOptions<LinkToAnotherRecordColumn>();
const model = await colOptions.getRelatedTable(); const model = await colOptions.getRelatedTable();
@ -306,25 +304,27 @@ export async function relDataList(param: {
dbDriver: await NcConnectionMgrv2.get(base), dbDriver: await NcConnectionMgrv2.get(base),
}); });
const { ast } = await getAst({ const { ast, dependencyFields } = await getAst({
query: param.query, query: param.query,
model, model,
extractOnlyPrimaries: true, extractOnlyPrimaries: true,
}); });
let data = []; let data = [];
let count = 0; let count = 0;
try { try {
data = data = await nocoExecute( data = data = await nocoExecute(
ast, ast,
await baseModel.list(param.query), await baseModel.list(dependencyFields),
{}, {},
param.query dependencyFields
); );
count = await baseModel.count(param.query); count = await baseModel.count(dependencyFields);
} catch (e) { } catch (e) {
// show empty result instead of throwing error here console.log(e);
// e.g. search some text in a numeric field NcError.internalServerError('Please check server log for more details');
} }
return new PagedResponseImpl(data, { ...param.query, count }); return new PagedResponseImpl(data, { ...param.query, count });

Loading…
Cancel
Save