fix default not trim
This commit is contained in:
@@ -147,7 +147,7 @@ private fun ScriptPart.getParameterDefault(): NextScript<String?> {
|
|||||||
.find(restOfScript)
|
.find(restOfScript)
|
||||||
.let { it ?: throw ParameterDefaultMalformed(this) }
|
.let { it ?: throw ParameterDefaultMalformed(this) }
|
||||||
.let { it.groups[2]!!.value }
|
.let { it.groups[2]!!.value }
|
||||||
.let { NextScript(it, "") }
|
.let { NextScript(it.trim(), "") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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" - {
|
"parameters with IN OUT INOUT" - {
|
||||||
val param = parseFunction(
|
val param = parseFunction(
|
||||||
// language=PostgreSQL
|
// language=PostgreSQL
|
||||||
|
|||||||
Reference in New Issue
Block a user