Inserting multiple rows, ordering, and inserting multiple relations. #3019
Unanswered
nobledossy
asked this question in
Q&A
Replies: 1 comment
-
According to this from the discord, it just exposes the db's returning method. I'm having this same issue because sqlite does not preserve the order: "The output order for the RETURNING rows is arbitrary and is not necessarily related to the order in which the rows were processed internally." And the lack of nested insert leaves no way to achieve this in drizzle in the scenario where you are not passing your own IDs in. So I guess we've gotta resort to raw sql. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm doing a fair amount of processing within a block of code and will need to update and/or create more than a few entries in numerous tables, all connected with one-to-many/many-to-one relationships in some way.
My understanding is that Drizzle does not support inserting multiple nested relations with a single insert call (I really hope I'm misinformed on that one), so I may have to do a bulk upsert for each table to keep overhead down. Are bulk operations guaranteed to return the array of newly-created objects in the exact same order of the array passed to the insert() function? Ie, I pass [entry1, entry2, entry3], all new objects with no IDs going in, or perhaps some exist and some don't. Will I get [entry1, entry2, entry3] back in that exact order every time? Because if order isn't guaranteed then that is going to make things more difficult as I have to keep all of these entries correlated to the correct object going into the database, then make sure I get the correct ID out of the returned results to link them. The alternative is doing everything one at a time, but that's going to have some really ugly overhead. I'm relatively new to Drizzle, so perhaps I'm missing something.
Beta Was this translation helpful? Give feedback.
All reactions