Removed extraneous findAll call from CRUD.updateAll (#3154)

* Removed extraneous findAll call from CRUD.updateAll

* Made update tests deal with unchanged element
This commit is contained in:
Nadav Kohen 2021-05-26 15:22:18 -05:00 committed by GitHub
parent 880c8898da
commit 17d1145504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -90,9 +90,15 @@ abstract class CRUD[T, PrimaryKeyType](implicit
} else {
val actions = ts.map(t => find(t).update(t))
for {
_ <- safeDatabase.runVec(DBIO.sequence(actions).transactionally)
result <- safeDatabase.runVec(findAll(ts).result)
} yield result
numUpdated <- safeDatabase.runVec(
DBIO.sequence(actions).transactionally)
tsUpdated <- {
if (numUpdated.sum == ts.length) Future.successful(ts)
else
Future.failed(new RuntimeException(
s"Unexpected number of updates completed ${numUpdated.sum} of ${ts.length}"))
}
} yield tsUpdated
}
}

View File

@ -54,7 +54,8 @@ sealed trait TestDAOFixture
val updatedDb: TestDb = testDb.copy(data = hex"0000")
val updatedDbs: Vector[TestDb] = testDbs.map(_.copy(data = hex"0000"))
val updatedDbs: Vector[TestDb] =
testDbs.init.map(_.copy(data = hex"0000")).:+(testDbs.last)
def testCreate(testDAO: TestDAO): Future[Boolean] = {
for {