feature add exec method

This commit is contained in:
2019-06-18 10:19:28 +02:00
parent 3b63f69f09
commit b3d9e7624b
2 changed files with 15 additions and 0 deletions

View File

@@ -1,11 +1,13 @@
package fr.postgresjson.connexion
import com.fasterxml.jackson.core.type.TypeReference
import com.github.jasync.sql.db.QueryResult
import com.github.jasync.sql.db.pool.ConnectionPool
import com.github.jasync.sql.db.postgresql.PostgreSQLConnection
import com.github.jasync.sql.db.postgresql.PostgreSQLConnectionBuilder
import fr.postgresjson.Serializer
import fr.postgresjson.entity.EntityI
import java.util.concurrent.CompletableFuture
class Connection(
private val database: String,
@@ -50,6 +52,10 @@ class Connection(
inline fun <T, reified R : List<EntityI<T?>?>> select(sql: String, values: List<Any?> = emptyList()): R = select(sql, object : TypeReference<R>() {}, values)
fun exec(sql: String, values: List<Any?> = emptyList()): CompletableFuture<QueryResult> {
return connect().sendPreparedStatement(sql, compileArgs(values))
}
private fun compileArgs(values: List<Any?>): List<Any?> {
return values.map {
if (it is EntityI<*>) {