|
|
@ -2450,8 +2450,11 @@ class BaseModelSqlv2 { |
|
|
|
if (!response) await this.execAndParse(query); |
|
|
|
if (!response) await this.execAndParse(query); |
|
|
|
response = await this.readByPk( |
|
|
|
response = await this.readByPk( |
|
|
|
this.extractCompositePK({ |
|
|
|
this.extractCompositePK({ |
|
|
|
rowId: |
|
|
|
rowId: this.extractCompositePK({ |
|
|
|
this.extractCompositePK({ rowId: insertObj[ag.column_name], insertObj, ag }), |
|
|
|
rowId: insertObj[ag.column_name], |
|
|
|
|
|
|
|
insertObj, |
|
|
|
|
|
|
|
ag, |
|
|
|
|
|
|
|
}), |
|
|
|
insertObj, |
|
|
|
insertObj, |
|
|
|
ag, |
|
|
|
ag, |
|
|
|
}), |
|
|
|
}), |
|
|
@ -2900,14 +2903,16 @@ class BaseModelSqlv2 { |
|
|
|
ag, |
|
|
|
ag, |
|
|
|
rowId, |
|
|
|
rowId, |
|
|
|
insertObj, |
|
|
|
insertObj, |
|
|
|
|
|
|
|
force = false, |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
ai?: Column<any>; |
|
|
|
ai?: Column<any>; |
|
|
|
ag?: Column<any>; |
|
|
|
ag?: Column<any>; |
|
|
|
rowId; |
|
|
|
rowId; |
|
|
|
insertObj: Record<string, any>; |
|
|
|
insertObj: Record<string, any>; |
|
|
|
|
|
|
|
force?: boolean; |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
// handle if composite primary key is used along with ai or ag
|
|
|
|
// handle if composite primary key is used along with ai or ag
|
|
|
|
if ((ai || ag) && this.model.primaryKeys?.length > 1) { |
|
|
|
if ((ai || ag) && (force || this.model.primaryKeys?.length > 1)) { |
|
|
|
// generate object with ai column and rest of the primary keys
|
|
|
|
// generate object with ai column and rest of the primary keys
|
|
|
|
const pkObj = {}; |
|
|
|
const pkObj = {}; |
|
|
|
for (const pk of this.model.primaryKeys) { |
|
|
|
for (const pk of this.model.primaryKeys) { |
|
|
@ -3239,6 +3244,7 @@ class BaseModelSqlv2 { |
|
|
|
ai: aiPkCol, |
|
|
|
ai: aiPkCol, |
|
|
|
ag: agPkCol, |
|
|
|
ag: agPkCol, |
|
|
|
insertObj: insertData, |
|
|
|
insertObj: insertData, |
|
|
|
|
|
|
|
force: true, |
|
|
|
}) || insertData, |
|
|
|
}) || insertData, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|