Fix/function with same name #34
@@ -10,13 +10,13 @@ class Requester(
|
||||
private val queries: MutableMap<String, Query> = mutableMapOf(),
|
||||
private val functions: MutableMap<String, Function> = mutableMapOf()
|
||||
) {
|
||||
constructor(connection: Connection): this(connection, mutableMapOf(), mutableMapOf())
|
||||
constructor(connection: Connection) : this(connection, mutableMapOf(), mutableMapOf())
|
||||
|
||||
constructor(
|
||||
connection: Connection,
|
||||
queriesDirectory: URI? = null,
|
||||
functionsDirectory: URI? = null
|
||||
): this(
|
||||
) : this(
|
||||
connection = connection,
|
||||
queries = queriesDirectory?.toQuery(connection) ?: mutableMapOf(),
|
||||
functions = functionsDirectory?.toFunction(connection) ?: mutableMapOf(),
|
||||
@@ -63,11 +63,10 @@ class Requester(
|
||||
|
||||
fun getQuery(path: String): Query = queries[path] ?: throw NoQueryDefined(path)
|
||||
|
||||
|
||||
fun <A> inTransaction(block: Requester.() -> A?): A? = connection.inTransaction {
|
||||
this@Requester.block()
|
||||
}
|
||||
|
||||
class NoFunctionDefined(name: String): Exception("No function defined for $name")
|
||||
class NoQueryDefined(path: String): Exception("No query defined in $path")
|
||||
class NoFunctionDefined(name: String) : Exception("No function defined for $name")
|
||||
class NoQueryDefined(path: String) : Exception("No query defined in $path")
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.nio.file.Path
|
||||
class Function(
|
||||
override val script: String,
|
||||
override val source: Path? = null
|
||||
): Resource, ParametersInterface {
|
||||
) : Resource, ParametersInterface {
|
||||
val returns: String
|
||||
override val name: String
|
||||
override val parameters: List<Parameter>
|
||||
@@ -48,7 +48,7 @@ class Function(
|
||||
}
|
||||
}
|
||||
|
||||
class FunctionNotFound(cause: Throwable? = null): Resource.ParseException("Function not found in script", cause)
|
||||
class FunctionNotFound(cause: Throwable? = null) : Resource.ParseException("Function not found in script", cause)
|
||||
|
||||
val definition: String
|
||||
get() {
|
||||
@@ -76,4 +76,3 @@ class Function(
|
||||
return other.script != this.script
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,4 +9,4 @@ internal enum class Algorithm(name: String) {
|
||||
internal fun String.hash(algorithm: Algorithm): String {
|
||||
val md = MessageDigest.getInstance(algorithm.name)
|
||||
return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user