Escaped parameters name

This commit is contained in:
2023-06-02 23:26:21 +02:00
parent 5c37481368
commit f4e88d385b
2 changed files with 20 additions and 1 deletions

View File

@@ -94,7 +94,7 @@ private fun ScriptPart.getParameterMode(): NextScript<Direction> {
@Throws(ParameterNameMalformed::class)
private fun ScriptPart.getParameterName(): NextScript<String> {
try {
return getNextScript { afterBeginBy(" ", "\n") }
return getNextScript { afterBeginBy(" ", "\n") && status.isNotEscaped() }
} catch (e: ParseException) {
throw ParameterNameMalformed(this, e)
}

View File

@@ -135,6 +135,25 @@ class FunctionTest : FreeSpec({
}
}
"Escaped parameters name" - {
val param = parseFunction(
// language=PostgreSQL
"""
create or replace function myfun("one""or two" text, "#@€" int) returns text language plpgsql as
$$ begin end;$$;
""".trimIndent()
).parameters
"should have 2 parameters" {
param shouldHaveSize 2
}
"should have names" {
param[0].name shouldBe "one\"or two"
param[1].name shouldBe "#@€"
}
}
"Parameters with type `character varying(255)`" - {
val param = parseFunction(
// language=PostgreSQL