From f741f0ae5371aafd2e6e8d026bf921d63b41e83d Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 30 Apr 2024 17:12:24 +0000 Subject: [PATCH] fix: handle manual pk --- packages/nocodb/src/db/BaseModelSqlv2.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 4137ee0065..0d2d6c2aa6 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -3255,6 +3255,17 @@ class BaseModelSqlv2 { } rowId = pkObj; } + + // handle if primary key is not ai or ag + if (!ai && !ag) { + const pkObj = {}; + for (const pk of this.model.primaryKeys) { + const key = pk.title; + pkObj[key] = insertObj[pk.column_name] ?? null; + } + rowId = pkObj; + } + return rowId; }