Browse Source

fix(gui): get record using autogenerated key if table using ag primary key

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4120/head
Pranav C 2 years ago
parent
commit
b78b38e53b
  1. 10
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

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

Loading…
Cancel
Save