package fr.postgresjson.connexion import com.fasterxml.jackson.core.type.TypeReference import com.github.jasync.sql.db.QueryResult import kotlin.jvm.Throws typealias SelectCallback = QueryResult.(R?) -> Unit sealed interface ExecutableRaw : Executable { /** * Select with [List] of parameters */ @Throws(DataNotFoundException::class) fun execute( sql: String, typeReference: TypeReference, values: List = emptyList(), block: SelectCallback = {} ): R? /** * Select with [Map] of parameters */ @Throws(DataNotFoundException::class) fun execute( sql: String, typeReference: TypeReference, values: Map, block: SelectCallback = {} ): R? /** * Select with multiple [Pair] of parameters */ @Throws(DataNotFoundException::class) fun execute( sql: String, typeReference: TypeReference, vararg values: Pair, block: SelectCallback = {} ): R? = execute(sql, typeReference, values.toMap(), block) fun exec(sql: String, value: R): QueryResult = exec(sql, listOf(value)) fun exec(sql: String, values: List): QueryResult fun exec(sql: String, values: Map): QueryResult fun exec(sql: String, vararg values: Pair): QueryResult = exec(sql, values.toMap()) /** * Warning: this method not use prepared statement */ fun sendQuery(sql: String, value: R): QueryResult = sendQuery(sql, listOf(value)) /** * Warning: this method not use prepared statement */ fun sendQuery(sql: String, values: List): QueryResult /** * Warning: this method not use prepared statement */ fun sendQuery(sql: String, values: Map): QueryResult /** * Warning: this method not use prepared statement */ fun sendQuery(sql: String, vararg values: Pair): QueryResult = sendQuery(sql, values.toMap()) }