WIP: Compiled SQL function #33
@@ -9,8 +9,8 @@ import com.github.jasync.sql.db.postgresql.PostgreSQLConnectionBuilder
|
|||||||
import com.github.jasync.sql.db.util.length
|
import com.github.jasync.sql.db.util.length
|
||||||
import fr.postgresjson.serializer.Serializer
|
import fr.postgresjson.serializer.Serializer
|
||||||
import fr.postgresjson.utils.LoggerDelegate
|
import fr.postgresjson.utils.LoggerDelegate
|
||||||
import kotlin.jvm.Throws
|
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
|
import kotlin.jvm.Throws
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import kotlin.reflect.full.hasAnnotation
|
import kotlin.reflect.full.hasAnnotation
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package fr.postgresjson.connexion
|
package fr.postgresjson.connexion
|
||||||
|
|
||||||
class DataNotFoundException(val queryExecuted: String): Exception() {
|
class DataNotFoundException(val queryExecuted: String) : Exception() {
|
||||||
override val message: String
|
override val message: String
|
||||||
get() = "No data return for the query"
|
get() = "No data return for the query"
|
||||||
}
|
}
|
||||||
@@ -31,14 +31,14 @@ class Function(
|
|||||||
.findAll(functionParameters)
|
.findAll(functionParameters)
|
||||||
.mapIndexed { index, paramsMatch ->
|
.mapIndexed { index, paramsMatch ->
|
||||||
Parameter(
|
Parameter(
|
||||||
paramsMatch.groups["pname"]?.value?.trim() ?: """arg${index+1}""",
|
paramsMatch.groups["pname"]?.value?.trim() ?: """arg${index + 1}""",
|
||||||
paramsMatch.groups["type"]?.value?.trim() ?: throw ArgumentNotFound(),
|
paramsMatch.groups["type"]?.value?.trim() ?: throw ArgumentNotFound(),
|
||||||
paramsMatch.groups["direction"]?.value?.trim(),
|
paramsMatch.groups["direction"]?.value?.trim(),
|
||||||
paramsMatch.groups["default"]?.value?.trim(),
|
paramsMatch.groups["default"]?.value?.trim(),
|
||||||
paramsMatch.groups["precision"]?.value?.trim()?.toInt(),
|
paramsMatch.groups["precision"]?.value?.trim()?.toInt(),
|
||||||
paramsMatch.groups["scale"]?.value?.trim()?.toInt()
|
paramsMatch.groups["scale"]?.value?.trim()?.toInt()
|
||||||
)
|
)
|
||||||
}.toList()
|
}.toList()
|
||||||
} else {
|
} else {
|
||||||
listOf()
|
listOf()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import fr.postgresjson.definition.Parameter.Direction.INOUT
|
|||||||
import fr.postgresjson.definition.Parameter.Direction.OUT
|
import fr.postgresjson.definition.Parameter.Direction.OUT
|
||||||
import fr.postgresjson.utils.searchSqlFiles
|
import fr.postgresjson.utils.searchSqlFiles
|
||||||
import fr.postgresjson.utils.toCamelCase
|
import fr.postgresjson.utils.toCamelCase
|
||||||
import java.io.File
|
|
||||||
import java.net.URI
|
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import java.io.File
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
class FunctionGenerator(private val functionsDirectories: List<URI>) {
|
class FunctionGenerator(private val functionsDirectories: List<URI>) {
|
||||||
constructor(functionsDirectories: URI): this(listOf(functionsDirectories))
|
constructor(functionsDirectories: URI) : this(listOf(functionsDirectories))
|
||||||
|
|
||||||
private val logger: Logger = LoggerFactory.getLogger("sqlFilesSearch")
|
private val logger: Logger = LoggerFactory.getLogger("sqlFilesSearch")
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import fr.postgresjson.serializer.deserialize
|
|||||||
import fr.postgresjson.serializer.toTypeReference
|
import fr.postgresjson.serializer.toTypeReference
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.TestInstance
|
import org.junit.jupiter.api.TestInstance
|
||||||
|
import org.junit.jupiter.api.assertThrows
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import kotlin.reflect.full.hasAnnotation
|
import kotlin.reflect.full.hasAnnotation
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
@@ -15,7 +16,6 @@ import kotlin.test.assertFalse
|
|||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
import kotlin.test.assertNull
|
import kotlin.test.assertNull
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import org.junit.jupiter.api.assertThrows
|
|
||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
class ConnectionTest : TestAbstract() {
|
class ConnectionTest : TestAbstract() {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.UUID
|
|||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
internal class SerializerTest {
|
internal class SerializerTest {
|
||||||
private class ObjTest(var val1: String, var val2: Int,val id: UUID = UUID.fromString("1e5f5d41-6d14-4007-897b-0ed2616bec96"))
|
private class ObjTest(var val1: String, var val2: Int, val id: UUID = UUID.fromString("1e5f5d41-6d14-4007-897b-0ed2616bec96"))
|
||||||
private class ObjTestDate(var val1: DateTime, val id: UUID = UUID.fromString("829b1a29-5db8-47f9-9562-961c561ac528"))
|
private class ObjTestDate(var val1: DateTime, val id: UUID = UUID.fromString("829b1a29-5db8-47f9-9562-961c561ac528"))
|
||||||
|
|
||||||
private val serializer = Serializer()
|
private val serializer = Serializer()
|
||||||
|
|||||||
Reference in New Issue
Block a user