Skip to content

Commit

Permalink
fix(core): ensure em.insertMany returns array of PKs for a single i…
Browse files Browse the repository at this point in the history
…tem too (#5180)

Closes #5179
  • Loading branch information
tkudlicka authored and B4nan committed Feb 4, 2024
1 parent 5acb4eb commit b9a55e5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/src/EntityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,11 @@ export class EntityManager<D extends IDatabaseDriver = IDatabaseDriver> {
data.forEach(row => em.validator.validateParams(row, 'insert data'));
const res = await em.driver.nativeInsertMany(entityName, data, { ctx: em.transactionContext, ...options });

return res.insertedIds!;
if (res.insertedIds) {
return res.insertedIds;
}

return [res.insertId];
}

/**
Expand Down

0 comments on commit b9a55e5

Please sign in to comment.