|
|
|
@ -2193,18 +2193,16 @@ class BaseModelSqlv2 {
|
|
|
|
|
await this.beforeInsert(insertObj, trx, cookie); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const columns = await this.model.getColumns(); |
|
|
|
|
const columns = await this.model.getColumns(); |
|
|
|
|
|
|
|
|
|
//remove auto increment columns if present in body
|
|
|
|
|
// exclude auto increment columns in body
|
|
|
|
|
for (const col of columns) { |
|
|
|
|
|
|
|
|
|
if (col.ai == true) { |
|
|
|
|
const keyName = data?.[col.column_name] !== undefined |
|
|
|
|
? col.column_name |
|
|
|
|
: col.title |
|
|
|
|
if (col.ai === true) { |
|
|
|
|
const keyName = |
|
|
|
|
data?.[col.column_name] !== undefined ? col.column_name : col.title; |
|
|
|
|
|
|
|
|
|
if (data[keyName]) { |
|
|
|
|
delete data[keyName] |
|
|
|
|
delete data[keyName]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2225,7 +2223,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) { |
|
|
|
|