scalaslickslick-3.0slick-2.0

Does Slick's DBIO.seq method run actions sequentially?


Slick has DBIO.seq and DBIO.sequence for running many DBIOActions whereby the results of previous actions aren't required for subsequent actions.

I've looked at the source, and it's not obvious to me if DBIO.seq runs the actions sequentially. On the other hand, DBIO.fold has a very simple implementation which definitely does run the actions sequentially, as it just uses flatMap internally.

My question is: will order be guaranteed when using seq and sequence, like it is with fold?


Solution

  • The documentation states that the actions in DBIO.seq are run sequentially:

    The simplest combinator is DBIO.seq which takes a varargs list of actions to run in sequence

    Also, in the source code for DBIO.seq, you will see that SynchronousDatabaseAction is called inside foreach, which means that each are sequantially and (internally) synchronously called without any parallel run.