diff --git a/src/main/kotlin/fr/postgresjson/definition/parse/ParsingHelper.kt b/src/main/kotlin/fr/postgresjson/definition/parse/ParsingHelper.kt index 6ec75de..3809ed7 100644 --- a/src/main/kotlin/fr/postgresjson/definition/parse/ParsingHelper.kt +++ b/src/main/kotlin/fr/postgresjson/definition/parse/ParsingHelper.kt @@ -156,7 +156,7 @@ internal data class Context( val script: String, ) { fun afterBeginBy(vararg texts: String): Boolean = texts.any { - script.drop(index + 1).take(it.length) == it + script.drop(index + 1).take(it.length).lowercase() == it.lowercase() } fun afterBeginBy(vararg texts: Regex): Boolean = texts.any { it.matchAt(script, index + 1) != null diff --git a/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt b/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt index 23a76e3..8f5810f 100644 --- a/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt +++ b/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt @@ -218,6 +218,32 @@ class FunctionTest : FreeSpec({ } } + "Parameters with default int" - { + val param = parseFunction( + // language=PostgreSQL + """ + create or replace function myfun(one int DEFAULT 123456 ) returns text language plpgsql as + $$ begin end;$$; + """.trimIndent() + ).parameters + + "should have 1 parameters" { + param shouldHaveSize 1 + } + + "should have name" { + param[0].name shouldBe "one" + } + + "should have type name" { + param[0].type.name shouldBe "int" + } + + "should have default text" { + param[0].default shouldBe "123456" + } + } + "parameters with IN OUT INOUT" - { val param = parseFunction( // language=PostgreSQL