|
|
|
@ -2193,7 +2193,21 @@ class BaseModelSqlv2 {
|
|
|
|
|
await this.beforeInsert(insertObj, trx, cookie); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await this.model.getColumns(); |
|
|
|
|
const columns = await this.model.getColumns(); |
|
|
|
|
|
|
|
|
|
//remove auto increment columns if present in body
|
|
|
|
|
for (const col of columns) { |
|
|
|
|
|
|
|
|
|
if (col.ai == true) { |
|
|
|
|
const keyName = data?.[col.column_name] !== undefined |
|
|
|
|
? col.column_name |
|
|
|
|
: col.title |
|
|
|
|
|
|
|
|
|
if (data[keyName]) { |
|
|
|
|
delete data[keyName] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await this.prepareAttachmentData(insertObj); |
|
|
|
|
|
|
|
|
@ -2211,7 +2225,7 @@ class BaseModelSqlv2 {
|
|
|
|
|
const ai = this.model.columns.find((c) => c.ai); |
|
|
|
|
|
|
|
|
|
let ag: Column; |
|
|
|
|
if (!ai) ag = this.model.columns.find((c) => c.meta?.ag); |
|
|
|
|
if (!ai) ag = this.model.columns.find((c) => c.meta?.ag);
|
|
|
|
|
|
|
|
|
|
// handle if autogenerated primary key is used
|
|
|
|
|
if (ag) { |
|
|
|
|