org.komapper.r2dbc.dsl.runner.R2dbcRelationUpdateRunner.kt Maven / Gradle / Ivy
package org.komapper.r2dbc.dsl.runner
import org.komapper.core.DatabaseConfig
import org.komapper.core.DryRunStatement
import org.komapper.core.dsl.context.RelationUpdateContext
import org.komapper.core.dsl.metamodel.EntityMetamodel
import org.komapper.core.dsl.runner.RelationUpdateRunner
import org.komapper.r2dbc.R2dbcDatabaseConfig
import org.komapper.r2dbc.R2dbcExecutor
internal class R2dbcRelationUpdateRunner>(
private val context: RelationUpdateContext,
) : R2dbcRunner {
private val runner: RelationUpdateRunner = RelationUpdateRunner(context)
override fun check(config: DatabaseConfig) {
runner.check(config)
}
override suspend fun run(config: R2dbcDatabaseConfig): Long {
val clock = config.clockProvider.now()
val updatedAtAssignment = context.target.updatedAtAssignment(clock)
val result = runner.buildStatement(config, updatedAtAssignment)
val statement = result.getOrNull()
return if (statement != null) {
val executor = R2dbcExecutor(config, context.options)
val (count) = executor.executeUpdate(statement)
count
} else {
0
}
}
override fun dryRun(config: DatabaseConfig): DryRunStatement {
return runner.dryRun(config)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy