Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v6.0.5 insertMany #5179

Closed
5 tasks done
tkudlicka opened this issue Jan 29, 2024 · 2 comments · Fixed by #5180
Closed
5 tasks done

v6.0.5 insertMany #5179

tkudlicka opened this issue Jan 29, 2024 · 2 comments · Fixed by #5180

Comments

@tkudlicka
Copy link
Contributor

Describe the bug

when i insert only one record, because i expecting 1 or more items i use insertMany, but when i insert only one, then returned ids insertIds are undefined and it should return insertedId from response in array
{ affectedRows: 1, insertId: 1, row: { id: 1 }, rows: [ { id: 1 } ] }

Reproduction

// Works as a workaround
await em.insertMany(
Test,
[{
test: "test"
}],
);

What driver are you using?

@mikro-orm/postgresql

MikroORM version

6.0.5

Node.js version

v18.18.2

Operating system

mac

Validations

@B4nan
Copy link
Member

B4nan commented Jan 29, 2024

I am not sure what you are reporting here. Your reproduction starts with a comment saying the code is a workaround? Also, it's a bit incomplete, e.g. no entity definition, ORM config, etc. Most importantly, there is no assert, so no notion of what you expect in the response, you don't even save the response anywhere...

@tkudlicka
Copy link
Contributor Author

tkudlicka commented Jan 29, 2024

at EntityManager should be for function insertMany last returnreturn data.length === 1 ? [res.insertedId] : res.insertedIds; instead of res.insertedIds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants