Skip to content

Commit

Permalink
Merge pull request #7946 from nocodb/fix/v2-insert-api-response
Browse files Browse the repository at this point in the history
fix: Use column title as alias in bulk insert return statement
  • Loading branch information
pranavxc committed Mar 23, 2024
2 parents 5fb78f1 + 74b3514 commit 1d54166
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/nocodb/src/db/BaseModelSqlv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3582,19 +3582,19 @@ class BaseModelSqlv2 {
);
}
} else {
const returningArr: string[] = [];
const returningObj: Record<string, string> = {};

if (!raw) {
for (const col of this.model.primaryKeys) {
returningArr.push(col.column_name);
returningObj[col.title] = col.column_name;
}
}

responses =
!raw && (this.isPg || this.isMssql)
? await trx
.batchInsert(this.tnPath, insertDatas, chunkSize)
.returning(this.model.primaryKeys?.length ? returningArr : '*')
.returning(this.model.primaryKeys?.length ? returningObj : '*')
: await trx.batchInsert(this.tnPath, insertDatas, chunkSize);
}

Expand Down Expand Up @@ -6622,7 +6622,12 @@ export function extractCondition(

if (aliasColObjMap[alias]) {
if (
[UITypes.Date, UITypes.DateTime, UITypes.LastModifiedTime, UITypes.CreatedTime].includes(aliasColObjMap[alias].uidt)
[
UITypes.Date,
UITypes.DateTime,
UITypes.LastModifiedTime,
UITypes.CreatedTime,
].includes(aliasColObjMap[alias].uidt)
) {
value = value?.split(',');
// the first element would be sub_op
Expand Down

0 comments on commit 1d54166

Please sign in to comment.