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

[BUG]: Bulk insert multiple entities without need to use spread operator #269

Closed
krzkaczor opened this issue Mar 15, 2023 · 6 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@krzkaczor
Copy link

krzkaczor commented Mar 15, 2023

What version of drizzle-orm are you using?

0.21.1

Describe the Bug

As far as I can tell, the only way to insert multiple entities in a single query with insert is to use values with multiple arguments (use spread operator) ie:

await db.insert(users).values(...newUsers)

This can easily lead to RangeError: Maximum call stack size exceeded if there are thousands (~20k and more) of entities being sent.

Passing entities as an array should mitigate this problem.

@krzkaczor krzkaczor added the bug Something isn't working label Mar 15, 2023
@dankochetov
Copy link
Contributor

Interesting! We weren't aware of that. Will work on implementing passing an array directly. Thanks!

@dankochetov
Copy link
Contributor

Fixed in 0.23.0

@krzkaczor
Copy link
Author

krzkaczor commented Apr 7, 2023

I think this is a commit that suppose to fix this (sidenote: maybe linking issues in PRs would help tracking it...).

This PR, unfortunately doesn't contain any tests and doesn't actually fix the problem. insert still blows up with Maximum call stack size exceeded when a lot of items are passed at once.

@AndriiSherman AndriiSherman reopened this Apr 7, 2023
@dankochetov
Copy link
Contributor

@krzkaczor are you passing the items as a regular array?

@krzkaczor
Copy link
Author

yes

@dankochetov dankochetov self-assigned this Apr 19, 2023
@jakeleventhal
Copy link

#797 (comment) Still an issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants