Browse Source

deleted columns with ai = true

pull/6878/head
Aashish Agrawal 1 year ago
parent
commit
915ccbd99a
  1. 16
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 6
      packages/nocodb/src/services/datas.service.ts

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

@ -2193,7 +2193,21 @@ class BaseModelSqlv2 {
await this.beforeInsert(insertObj, trx, cookie); 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); await this.prepareAttachmentData(insertObj);

6
packages/nocodb/src/services/datas.service.ts

@ -63,7 +63,7 @@ export class DatasService {
async dataInsert( async dataInsert(
param: PathParams & { param: PathParams & {
body: any; body: unknown;
cookie: any; cookie: any;
disableOptimization?: boolean; disableOptimization?: boolean;
}, },
@ -78,10 +78,6 @@ export class DatasService {
dbDriver: await NcConnectionMgrv2.get(source), dbDriver: await NcConnectionMgrv2.get(source),
}); });
if (param?.body?.Id) {
delete param?.body?.Id
}
return await baseModel.insert(param.body, null, param.cookie); return await baseModel.insert(param.body, null, param.cookie);
} }

Loading…
Cancel
Save