Added workaround to KT-2493 to get maven build back to life.

This commit is contained in:
Evgeny Gerashchenko
2012-07-23 19:21:43 +04:00
parent 3af9540702
commit 45672cf7e2
3 changed files with 8 additions and 8 deletions
@@ -10,7 +10,7 @@ import java.math.BigDecimal
fun <T> Connection.statement(block: (Statement) -> T): T { fun <T> Connection.statement(block: (Statement) -> T): T {
val statement = createStatement() val statement = createStatement()
if (statement != null) { if (statement != null) {
return statement.use(block) return statement.useSql(block)
} else { } else {
throw IllegalStateException("No Statement returned from $this") 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 * 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() val connection = getConnection()
if (connection != null) { if (connection != null) {
try { try {
@@ -24,33 +24,33 @@ fun <T> DataSource.use(block : (Connection) -> T): T {
* Helper method to process a statement on this collection * Helper method to process a statement on this collection
*/ */
fun <T> DataSource.statement(block: (Statement) -> T): T { 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 * Perform an SQL update on the connection
*/ */
fun DataSource.update(sql: String): Int { 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 * Perform a query on the connection and processes the result set with a function
*/ */
fun <T> DataSource.query(sql: String, block: (ResultSet) -> T): T { 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]] * Performs the update using the given SQL using a [[StringTemplate]]
*/ */
fun DataSource.update(template : StringTemplate) : Int { 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 * 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 { 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 * 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 { try {
return block(this) return block(this)
} finally { } finally {