Browse Source

fix: extract id for ag

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6953/head
mertmit 1 year ago
parent
commit
09ecf174e3
  1. 17
      packages/nocodb/src/db/BaseModelSqlv2.ts

17
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -2621,7 +2621,20 @@ class BaseModelSqlv2 {
} }
const ai = this.model.columns.find((c) => c.ai); 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.execAndParse(query);
response = await this.readByPk(
data[ag.title],
false,
{},
{ ignoreView: true, getHiddenColumn: true },
);
} else if (
!response || !response ||
(typeof response?.[0] !== 'object' && response?.[0] !== null) (typeof response?.[0] !== 'object' && response?.[0] !== null)
) { ) {
@ -2680,12 +2693,14 @@ class BaseModelSqlv2 {
await Promise.all(postInsertOps.map((f) => f(rowId))); await Promise.all(postInsertOps.map((f) => f(rowId)));
if (rowId !== null && rowId !== undefined) {
response = await this.readByPk( response = await this.readByPk(
rowId, rowId,
false, false,
{}, {},
{ ignoreView: true, getHiddenColumn: true }, { ignoreView: true, getHiddenColumn: true },
); );
}
await this.afterInsert(response, this.dbDriver, cookie); await this.afterInsert(response, this.dbDriver, cookie);

Loading…
Cancel
Save