Added workaround to KT-2493 to get maven build back to life.
This commit is contained in:
@@ -10,7 +10,7 @@ import java.math.BigDecimal
|
||||
fun <T> Connection.statement(block: (Statement) -> T): T {
|
||||
val statement = createStatement()
|
||||
if (statement != null) {
|
||||
return statement.use(block)
|
||||
return statement.useSql(block)
|
||||
} else {
|
||||
throw IllegalStateException("No Statement returned from $this")
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import kotlin.template.StringTemplate
|
||||
/**
|
||||
* Processes a connection from the pool using the given function block
|
||||
*/
|
||||
fun <T> DataSource.use(block : (Connection) -> T): T {
|
||||
fun <T> DataSource.useDataSource(block : (Connection) -> T): T { // TODO rename to "use" when KT-2493 is fixed
|
||||
val connection = getConnection()
|
||||
if (connection != null) {
|
||||
try {
|
||||
@@ -24,33 +24,33 @@ fun <T> DataSource.use(block : (Connection) -> T): T {
|
||||
* Helper method to process a statement on this collection
|
||||
*/
|
||||
fun <T> DataSource.statement(block: (Statement) -> T): T {
|
||||
return use{ it.statement(block) }
|
||||
return useDataSource{ it.statement(block) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an SQL update on the connection
|
||||
*/
|
||||
fun DataSource.update(sql: String): Int {
|
||||
return use{ it.update(sql) }
|
||||
return useDataSource{ it.update(sql) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a query on the connection and processes the result set with a function
|
||||
*/
|
||||
fun <T> DataSource.query(sql: String, block: (ResultSet) -> T): T {
|
||||
return use{ it.query(sql, block) }
|
||||
return useDataSource{ it.query(sql, block) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the update using the given SQL using a [[StringTemplate]]
|
||||
*/
|
||||
fun DataSource.update(template : StringTemplate) : Int {
|
||||
return use{ it.update(template) }
|
||||
return useDataSource{ it.update(template) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a query on the connection using the SQL from the [[StringTemplate]] and processes the result set with a function
|
||||
*/
|
||||
fun <T> DataSource.query(template : StringTemplate, resultBlock : (ResultSet) -> T) : T {
|
||||
return use{ it.query(template, resultBlock) }
|
||||
return useDataSource{ it.query(template, resultBlock) }
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.sql.Statement
|
||||
/**
|
||||
* Uses the statement with the given block then closes the statement
|
||||
*/
|
||||
fun <T, S : Statement> S.use(block : (S) -> T) : T {
|
||||
fun <T, S : Statement> S.useSql(block : (S) -> T) : T { // TODO rename to "use" when KT-2493 is fixed
|
||||
try {
|
||||
return block(this)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user