Skip to content

Commit d948b6a

Browse files
committed
Merge branch 'fix-example-spec' of git://github.com/kxbmap/scalikejdbc-async into kxbmap-fix-example-spec
2 parents 2f62c48 + 891be57 commit d948b6a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/test/scala/programmerlist/ExampleSpec.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ class ExampleSpec extends FlatSpec with ShouldMatchers with DBSettings with Logg
3737
// delete a record and rollback
3838
val withinTx: Future[Unit] = AsyncDB.localTx { implicit tx =>
3939
for {
40-
restructuring <- Programmer.findAllBy(sqls.eq(p.companyId, newCompany.id)).map { programmers =>
41-
programmers.foreach(_.destroy())
40+
programmers <- Programmer.findAllBy(sqls.eq(p.companyId, newCompany.id))
41+
restructuring <- programmers.foldLeft(Future.successful()) {
42+
(prev, programmer) =>
43+
for {
44+
_ <- prev
45+
_ <- programmer.destroy()
46+
} yield ()
4247
}
4348
dissolution <- newCompany.destroy()
4449
_ <- sql"Just joking!".update.future

0 commit comments

Comments
 (0)