WIP: Compiled SQL function #33

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

View File

@@ -147,7 +147,7 @@ private fun ScriptPart.getParameterDefault(): NextScript<String?> {
.find(restOfScript)
.let { it ?: throw ParameterDefaultMalformed(this) }
.let { it.groups[2]!!.value }
.let { NextScript(it, "") }
.let { NextScript(it.trim(), "") }
}
}

View File

@@ -244,6 +244,38 @@ class FunctionTest : FreeSpec({
}
}
"Parameters with multiple default and equal" - {
val param = parseFunction(
// language=PostgreSQL
"""
create or replace function myfun(one int DEFAULT 123456 , two text default 'hello', three text = '654') returns text language plpgsql as
$$ begin end;$$;
""".trimIndent()
).parameters
"should have 3 parameters" {
param shouldHaveSize 3
}
"should have name" {
param[0].name shouldBe "one"
param[1].name shouldBe "two"
param[2].name shouldBe "three"
}
"should have type name" {
param[0].type.name shouldBe "int"
param[1].type.name shouldBe "text"
param[2].type.name shouldBe "text"
}
"should have default text" {
param[0].default shouldBe "123456"
param[1].default shouldBe "'hello'"
param[2].default shouldBe "'654'"
}
}
"parameters with IN OUT INOUT" - {
val param = parseFunction(
// language=PostgreSQL