Skip to content

Does batch method run its statements in order? #974

Answered by simolus3
cervonwong asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

the order was undefined in older moor versions, but we now guarantee that batches run statements in the order in which they were issued (and we have tests for that!). This is also true for each row inside an insertAll call.
I don't know the exact moor version where this was changed, but if you're on 3.4.0 you should be safe.

(so that the autogenerated IDs can be predicted)

Note that, if you do

final id = await currentAutoGeneratedId();
final batch = await batch(() {
  // assume that rows start at id
});

There could be some interleaving between await currentAutoGeneratedId() and await batch() if you run another insert concurrently. If you want to be safe, wrap the select and the batc…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cervonwong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants