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 fr.postgresjson.serializer.Serializer
|
||||
import fr.postgresjson.utils.LoggerDelegate
|
||||
import kotlin.jvm.Throws
|
||||
import org.slf4j.Logger
|
||||
import kotlin.jvm.Throws
|
||||
import kotlin.random.Random
|
||||
import kotlin.reflect.full.hasAnnotation
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package fr.postgresjson.connexion
|
||||
|
||||
class DataNotFoundException(val queryExecuted: String): Exception() {
|
||||
class DataNotFoundException(val queryExecuted: String) : Exception() {
|
||||
override val message: String
|
||||
get() = "No data return for the query"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package fr.postgresjson.connexion
|
||||
|
||||
sealed interface Executable
|
||||
sealed interface Executable
|
||||
|
||||
@@ -31,14 +31,14 @@ class Function(
|
||||
.findAll(functionParameters)
|
||||
.mapIndexed { index, paramsMatch ->
|
||||
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["direction"]?.value?.trim(),
|
||||
paramsMatch.groups["default"]?.value?.trim(),
|
||||
paramsMatch.groups["precision"]?.value?.trim()?.toInt(),
|
||||
paramsMatch.groups["scale"]?.value?.trim()?.toInt()
|
||||
)
|
||||
}.toList()
|
||||
}.toList()
|
||||
} else {
|
||||
listOf()
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import fr.postgresjson.definition.Parameter.Direction.INOUT
|
||||
import fr.postgresjson.definition.Parameter.Direction.OUT
|
||||
import fr.postgresjson.utils.searchSqlFiles
|
||||
import fr.postgresjson.utils.toCamelCase
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.net.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")
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import fr.postgresjson.serializer.deserialize
|
||||
import fr.postgresjson.serializer.toTypeReference
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import java.util.UUID
|
||||
import kotlin.reflect.full.hasAnnotation
|
||||
import kotlin.test.assertEquals
|
||||
@@ -15,7 +16,6 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class ConnectionTest : TestAbstract() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.UUID
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
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 val serializer = Serializer()
|
||||
|
||||
@@ -92,4 +92,4 @@ class FunctionGeneratorTest : StringSpec({
|
||||
|
||||
generator.generate(Function(functionSql)) `should be equal to` expectedGenerated
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user