From 02d09cc7676c9e7490741834cf12bbb1771d38ea Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 30 Nov 2023 11:58:45 +0530 Subject: [PATCH] fix: error message correction Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 30 +++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index ad5b7dcc80..3039d05e2d 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -4869,7 +4869,9 @@ class BaseModelSqlv2 { ); NcError.unprocessableEntity( - `Child record with id [${missingIds.join(', ')}] not found`, + `Child record with id [${extractIdsString( + missingIds, + )}] not found`, ); } @@ -4933,7 +4935,9 @@ class BaseModelSqlv2 { ); NcError.unprocessableEntity( - `Child record with id [${missingIds.join(', ')}] not found`, + `Child record with id [${extractIdsString( + missingIds, + )}] not found`, ); } } @@ -4983,7 +4987,9 @@ class BaseModelSqlv2 { if (!childRow) { NcError.unprocessableEntity( - `Child record with id [${childIds[0]}] not found`, + `Child record with id [${extractIdsString( + childIds, + )}] not found`, ); } } @@ -5109,7 +5115,9 @@ class BaseModelSqlv2 { ); NcError.unprocessableEntity( - `Child record with id [${missingIds.join(', ')}] not found`, + `Child record with id [${extractIdsString( + missingIds, + )}] not found`, ); } } @@ -5157,7 +5165,9 @@ class BaseModelSqlv2 { ); NcError.unprocessableEntity( - `Child record with id [${missingIds.join(', ')}] not found`, + `Child record with id [${extractIdsString( + missingIds, + )}] not found`, ); } } @@ -5211,7 +5221,9 @@ class BaseModelSqlv2 { if (!childRow) { NcError.unprocessableEntity( - `Child record with id [${childIds[0]}] not found`, + `Child record with id [${extractIdsString( + childIds, + )}] not found`, ); } } @@ -5677,4 +5689,10 @@ export function getListArgs( return obj; } +function extractIdsString(childIds: (string | number | Record)[]) { + return childIds + .map((r) => (typeof r === 'object' ? JSON.stringify(r) : r)) + .join(', '); +} + export { BaseModelSqlv2 };