|
|
@ -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); |
|
|
|
|
|
|
|
|
|
|
|