From 598b3d761c452acc60449f8fc429eefd8ac6f0fb Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 7 Jun 2023 13:03:51 +0530 Subject: [PATCH 1/2] fix: if record not found then return null rather than returning empty object Signed-off-by: Pranav C --- packages/nocodb/src/db/BaseModelSqlv2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 86e2a96431..1d5c356a2f 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -172,7 +172,7 @@ class BaseModelSqlv2 { data.__proto__ = proto; } - return data ? await nocoExecute(ast, data, {}, query) : {}; + return data ? await nocoExecute(ast, data, {}, query) : null; } public async exist(id?: any): Promise { From c40c41cad3dc1a602ce63092d2fe93fd2c071b70 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 7 Jun 2023 13:45:25 +0530 Subject: [PATCH 2/2] test: update the test Signed-off-by: Pranav C --- packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts b/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts index 13075be5fb..c09472d672 100644 --- a/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts +++ b/packages/nocodb/tests/unit/model/tests/baseModelSql.test.ts @@ -282,7 +282,7 @@ function baseModelSqlTests() { const deletedRow = await baseModelSql.readByPk(rowIdToDeleted); - expect(deletedRow).to.be.an('object').that.is.empty; + expect(deletedRow).to.be.null; console.log('Delete record', await Audit.projectAuditList(project.id, {})); const rowDeletedAudit = (await Audit.projectAuditList(project.id, {})).find(