Browse Source

Merge pull request #6878 from aashishagrawall/bug/5871

fix: Auto increment field ID not ignored if sent in API payload
pull/7055/head
Pranav C 1 year ago committed by GitHub
parent
commit
7dc647ec3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      packages/nocodb/src/db/BaseModelSqlv2.ts

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

@ -2277,6 +2277,22 @@ class BaseModelSqlv2 {
async insert(data, trx?, cookie?, _disableOptimization = false) {
try {
const columns = await this.model.getColumns();
// exclude auto increment columns in body
for (const col of columns) {
if (col.ai) {
const keyName =
data?.[col.column_name] !== undefined ? col.column_name : col.title;
if (data[keyName]) {
delete data[keyName];
}
}
}
await populatePk(this.model, data);
// todo: filter based on view
@ -2291,9 +2307,6 @@ class BaseModelSqlv2 {
if ('beforeInsert' in this) {
await this.beforeInsert(insertObj, trx, cookie);
}
await this.model.getColumns();
await this.prepareAttachmentData(insertObj);
let response;

Loading…
Cancel
Save