Browse Source

fix: error strings

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/7025/head
Raju Udava 1 year ago
parent
commit
bbde7bba0b
  1. 6
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 4
      packages/nocodb/src/db/conditionV2.ts
  3. 4
      packages/nocodb/src/db/sortV2.ts
  4. 2
      packages/nocodb/src/helpers/catchError.ts
  5. 4
      packages/nocodb/src/helpers/getAst.ts

6
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -5194,9 +5194,7 @@ export function extractSortsObject(
else sort.fk_column_id = aliasColObjMap[s.replace(/^\+/, '')]?.id;
if (throwErrorIfInvalid && !sort.fk_column_id)
NcError.unprocessableEntity(
`Invalid field '${s.replace(/^[+-]/, '')}' in sort`,
);
NcError.unprocessableEntity(`Invalid field: ${s.replace(/^[+-]/, '')}`);
return new Sort(sort);
});
@ -5360,7 +5358,7 @@ export function extractCondition(
validateFilterComparison(aliasColObjMap[alias].uidt, op, sub_op);
} else if (throwErrorIfInvalid) {
NcError.unprocessableEntity(`Invalid field '${alias}' in Query`);
NcError.unprocessableEntity(`Invalid field: ${alias}`);
}
return new Filter({

4
packages/nocodb/src/db/conditionV2.ts

@ -155,9 +155,7 @@ const parseConditionV2 = async (
const column = await filter.getColumn();
if (!column) {
if (throwErrorIfInvalid) {
NcError.unprocessableEntity(
`Invalid field ID '${filter.fk_column_id}' in Query`,
);
NcError.unprocessableEntity(`Invalid field: ${filter.fk_column_id}`);
}
return;
}

4
packages/nocodb/src/db/sortV2.ts

@ -36,9 +36,7 @@ export default async function sortV2(
const column = await sort.getColumn();
if (!column) {
if (throwErrorIfInvalid) {
NcError.unprocessableEntity(
`Invalid field ID '${sort.fk_column_id}' in Query`,
);
NcError.unprocessableEntity(`Invalid field: ${sort.fk_column_id}`);
}
continue;
}

2
packages/nocodb/src/helpers/catchError.ts

@ -324,7 +324,7 @@ export function extractDBError(error): {
/ Invalid object name '(\w+)'./i,
);
const extractMissingColMatch = error.message.match(
/ Invalid field '(\w+)'./i,
/ Invalid field: (\w+)./i,
);
if (extractTableNameMatch && extractTableNameMatch[1]) {

4
packages/nocodb/src/helpers/getAst.ts

@ -73,9 +73,7 @@ const getAst = async ({
(f) => !colAliasMap[f] && !aliasColMap[f],
);
if (invalidFields.length) {
NcError.unprocessableEntity(
`Invalid field '${invalidFields[0]}' in Query`,
);
NcError.unprocessableEntity(`Invalid field: ${invalidFields[0]}`);
}
}
} else {

Loading…
Cancel
Save