diff --git a/src/main/kotlin/fr/postgresjson/connexion/EmbedExecutable.kt b/src/main/kotlin/fr/postgresjson/connexion/EmbedExecutable.kt index d77677c..eaccfe1 100644 --- a/src/main/kotlin/fr/postgresjson/connexion/EmbedExecutable.kt +++ b/src/main/kotlin/fr/postgresjson/connexion/EmbedExecutable.kt @@ -79,6 +79,15 @@ sealed interface EmbedExecutable { ): List = select(typeReference, values.toMap(), block) + /** + * Select Multiple or One [EntityI] with multiple [Pair] of parameters + */ + fun selectAny( + typeReference: TypeReference, + values: Map, + block: QueryResult.(R) -> Unit = {} + ): R + /* Select Paginated */ /** diff --git a/src/main/kotlin/fr/postgresjson/connexion/Executable.kt b/src/main/kotlin/fr/postgresjson/connexion/Executable.kt index d4be1a5..0c240ae 100644 --- a/src/main/kotlin/fr/postgresjson/connexion/Executable.kt +++ b/src/main/kotlin/fr/postgresjson/connexion/Executable.kt @@ -74,6 +74,16 @@ interface Executable { block: SelectCallback = {} ): List + /** + * Select Multiple or One [EntityI] with [Map] of parameters + */ + fun selectAny( + sql: String, + typeReference: TypeReference, + values: Map, + block: QueryResult.(R) -> Unit = {} + ): R + /** * Select Multiple [EntityI] with multiple [Pair] of parameters */ diff --git a/src/main/kotlin/fr/postgresjson/connexion/Function.kt b/src/main/kotlin/fr/postgresjson/connexion/Function.kt index 83096f6..e2bce37 100644 --- a/src/main/kotlin/fr/postgresjson/connexion/Function.kt +++ b/src/main/kotlin/fr/postgresjson/connexion/Function.kt @@ -56,6 +56,13 @@ class Function(val definition: Function, override val connection: Connection) : ): List = connection.select(compileSql(values), typeReference, values, block) + override fun selectAny( + typeReference: TypeReference, + values: Map, + block: QueryResult.(R) -> Unit + ): R = + connection.selectAny(compileSql(values.toMap()), typeReference, values.toMap(), block) + /* Select Paginated */ /** diff --git a/src/main/kotlin/fr/postgresjson/connexion/Query.kt b/src/main/kotlin/fr/postgresjson/connexion/Query.kt index b2851c9..3d23d9b 100644 --- a/src/main/kotlin/fr/postgresjson/connexion/Query.kt +++ b/src/main/kotlin/fr/postgresjson/connexion/Query.kt @@ -67,6 +67,12 @@ class Query(override val name: String, private val sql: String, override val con ): Paginated = connection.select(sql, page, limit, typeReference, values, block) + override fun selectAny( + typeReference: TypeReference, + values: Map, + block: QueryResult.(R) -> Unit + ): R = connection.selectAny(sql, typeReference, values.toMap(), block) + /* Execute function without treatments */ override fun exec(values: List): QueryResult = connection.exec(sql, values) diff --git a/src/main/kotlin/fr/postgresjson/serializer/Serializer.kt b/src/main/kotlin/fr/postgresjson/serializer/Serializer.kt index df8e250..45a3da1 100644 --- a/src/main/kotlin/fr/postgresjson/serializer/Serializer.kt +++ b/src/main/kotlin/fr/postgresjson/serializer/Serializer.kt @@ -28,7 +28,7 @@ class Serializer(val mapper: ObjectMapper = jacksonObjectMapper()) { } fun deserialize(json: String, valueTypeRef: TypeReference): E { - return this.mapper.readValue(json, valueTypeRef) + return mapper.readValue(json, valueTypeRef) } inline fun deserialize(json: String): E? {