Browse Source

refactor: improved error message

pull/8571/head
Pranav C 1 month ago
parent
commit
b779114cb1
  1. 11
      packages/nocodb/src/meta/meta.service.ts

11
packages/nocodb/src/meta/meta.service.ts

@ -447,7 +447,7 @@ export class MetaService {
// Check if a condition is present in the query builder and throw an error if not. // Check if a condition is present in the query builder and throw an error if not.
if (!force) { if (!force) {
this.checkConditionPresent(query); this.checkConditionPresent(query, 'delete');
} }
return query.del(); return query.del();
@ -726,7 +726,7 @@ export class MetaService {
// Check if a condition is present in the query builder and throw an error if not. // Check if a condition is present in the query builder and throw an error if not.
if (!force) { if (!force) {
this.checkConditionPresent(query); this.checkConditionPresent(query, 'update');
} }
return await query; return await query;
@ -1206,7 +1206,10 @@ export class MetaService {
* *
* @param queryBuilder - The Knex QueryBuilder instance to check. * @param queryBuilder - The Knex QueryBuilder instance to check.
*/ */
private checkConditionPresent(queryBuilder: Knex.QueryBuilder) { private checkConditionPresent(
queryBuilder: Knex.QueryBuilder,
operation: 'delete' | 'update',
) {
// Convert the query builder to a SQL string to inspect the presence of a WHERE clause. // Convert the query builder to a SQL string to inspect the presence of a WHERE clause.
const sql = queryBuilder.toString(); const sql = queryBuilder.toString();
@ -1219,7 +1222,7 @@ export class MetaService {
// Throw an error if no condition is found in the query builder. // Throw an error if no condition is found in the query builder.
NcError.metaError({ NcError.metaError({
message: 'Condition is required', message: 'A condition is required to ' + operation + ' records.',
sql, sql,
}); });
} }

Loading…
Cancel
Save