From b78b38e53b9b04e37579197fba58dd183b2e0150 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 17 Oct 2022 17:38:42 +0530 Subject: [PATCH] fix(gui): get record using autogenerated key if table using ag primary key Signed-off-by: Pranav C --- .../lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index 9d44175369..c998e09c9d 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -1431,7 +1431,15 @@ class BaseModelSqlv2 { } const ai = this.model.columns.find((c) => c.ai); - if ( + + let ag: Column; + if (!ai) ag = this.model.columns.find((c) => c.meta?.ag); + + // handle if autogenerated primary key is used + if (ag) { + if (!response) await this.extractRawQueryAndExec(query); + response = await this.readByPk(data[ag.title]); + } else if ( !response || (typeof response?.[0] !== 'object' && response?.[0] !== null) ) {