File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed
frameworks/Kotlin/ktor/ktor-r2dbc/src/main/kotlin/org/jetbrains/ktor/benchmarks Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -134,19 +134,15 @@ fun Application.main() {
134134 worldsUpdated.add(world)
135135 }
136136
137- Mono .usingWhen(dbConnFactory.create(), { connection ->
138- val statement = connection.createStatement(UPDATE_QUERY )
139- worldsUpdated.forEach { world ->
140- statement.bind(" $1" , world.randomNumber)
141- statement.bind(" $2" , world.id)
142- statement.add()
143- }
144- if (worldsUpdated.isNotEmpty()) {
145- Mono .from(statement.execute())
146- } else {
147- Mono .empty()
148- }
149- }, Connection ::close).awaitFirstOrNull()
137+ // Execute updates sequentially
138+ worldsUpdated.forEach { world ->
139+ Mono .usingWhen(dbConnFactory.create(), { connection ->
140+ Mono .from(connection.createStatement(UPDATE_QUERY )
141+ .bind(" $1" , world.randomNumber)
142+ .bind(" $2" , world.id)
143+ .execute())
144+ }, Connection ::close).awaitFirstOrNull()
145+ }
150146
151147 call.respondText(json.encodeToString(worldsUpdated), ContentType .Application .Json )
152148 }
You can’t perform that action at this time.
0 commit comments