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) ) {