diff --git a/src/main/kotlin/fr/postgresjson/definition/parse/ParsingFunction.kt b/src/main/kotlin/fr/postgresjson/definition/parse/ParsingFunction.kt index 6f3845b..d6028f1 100644 --- a/src/main/kotlin/fr/postgresjson/definition/parse/ParsingFunction.kt +++ b/src/main/kotlin/fr/postgresjson/definition/parse/ParsingFunction.kt @@ -127,7 +127,7 @@ private fun ScriptPart.getParameterType(): NextScript { .apply { rest = nextScriptPart } rest = rest.trimStart(' ', '\n', '\t', ')') - val isArray = rest.restOfScript.contains("[]") + val isArray = rest.restOfScript.contains("""\[[0-9]*]""".toRegex()) return NextScript( ParameterType( diff --git a/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt b/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt index c158495..600f13b 100644 --- a/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt +++ b/src/test/kotlin/fr/postgresjson/definition/FunctionTest.kt @@ -381,6 +381,44 @@ class FunctionTest : FreeSpec({ param[2].direction shouldBe IN } } + + "Parameters with type array multidimensional of text" - { + val param = parseFunction( + // language=PostgreSQL + """ + create or replace function myfun(one text[][]) language plpgsql as + $$ begin end;$$; + """.trimIndent() + ).parameters + + "should have parameter type is array" { + param[0].type.isArray shouldBe true + } + + "should have parameter type name" { + param[0].type.name shouldBe "text" + } + } + + "Parameters with type fixed size array" - { + val param = parseFunction( + // language=PostgreSQL + """ + create or replace function myfun(one text[45], two text[1][]) language plpgsql as + $$ begin end;$$; + """.trimIndent() + ).parameters + + "should have parameter type is array" { + param[0].type.isArray shouldBe true + param[1].type.isArray shouldBe true + } + + "should have parameter type name" { + param[0].type.name shouldBe "text" + param[1].type.name shouldBe "text" + } + } } "Function Returns" - {