WIP: Compiled SQL function #33

Draft
flecomte wants to merge 37 commits from compiled_sql_function into master
5 changed files with 33 additions and 1 deletions
Showing only changes of commit 79d2e52978 - Show all commits

View File

@@ -79,6 +79,15 @@ sealed interface EmbedExecutable {
): List<R> =
select(typeReference, values.toMap(), block)
/**
* Select Multiple or One [EntityI] with multiple [Pair] of parameters
*/
fun <R : Any?> selectAny(
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: QueryResult.(R) -> Unit = {}
): R
/* Select Paginated */
/**

View File

@@ -74,6 +74,16 @@ interface Executable {
block: SelectCallback<R> = {}
): List<R>
/**
* Select Multiple or One [EntityI] with [Map] of parameters
*/
fun <R : Any?> selectAny(
sql: String,
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: QueryResult.(R) -> Unit = {}
): R
/**
* Select Multiple [EntityI] with multiple [Pair] of parameters
*/

View File

@@ -56,6 +56,13 @@ class Function(val definition: Function, override val connection: Connection) :
): List<R> =
connection.select(compileSql(values), typeReference, values, block)
override fun <R : Any?> selectAny(
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: QueryResult.(R) -> Unit
): R =
connection.selectAny(compileSql(values.toMap()), typeReference, values.toMap(), block)
/* Select Paginated */
/**

View File

@@ -67,6 +67,12 @@ class Query(override val name: String, private val sql: String, override val con
): Paginated<R> =
connection.select(sql, page, limit, typeReference, values, block)
override fun <R> selectAny(
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: QueryResult.(R) -> Unit
): R = connection.selectAny(sql, typeReference, values.toMap(), block)
/* Execute function without treatments */
override fun exec(values: List<Any?>): QueryResult = connection.exec(sql, values)

View File

@@ -28,7 +28,7 @@ class Serializer(val mapper: ObjectMapper = jacksonObjectMapper()) {
}
fun <E> deserialize(json: String, valueTypeRef: TypeReference<E>): E {
return this.mapper.readValue(json, valueTypeRef)
return mapper.readValue(json, valueTypeRef)
}
inline fun <reified E> deserialize(json: String): E? {