run.smt.ktest.db.query.procedure-queries.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktest-db Show documentation
Show all versions of ktest-db Show documentation
Database intergration for kTest
package run.smt.ktest.db.query
import run.smt.ktest.db.query.impl.ProcedureBuilderImpl
import org.springframework.jdbc.core.JdbcTemplate
import javax.sql.DataSource
import java.sql.Date as SqlDate
/**
* Callable query
*/
inline fun DataSource.call(query: String? = null, build: ProcedureBuilder.() -> Unit): Response {
val builder = ProcedureBuilderImpl(query)
builder.mapTo = T::class
builder.build()
return builder.execute(JdbcTemplate(this))
}
inline fun DataSource.call(query: String): Response = call(query) {}
fun DataSource.execute(procedure: String?, build: PlainProcedureBuilder.() -> Unit) {
call(procedure, build).single()
}
fun DataSource.execute(procedure: String) = execute(procedure) {}
private class NoArg