Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ object PgFunctionFileParser extends GenericFileParser[FunctionFromSource] {
// 7 - capturing-group #3 - parameters are matched there as a block - \s also covers line-breaks => parsed further later


private val singleParamCapturingRx = """(?i)\s*(IN|OUT)\s+(\w+)\s+(\w+)\s*""".r // used to break up params from ^^
// 1--1 2------2 3---3 4---4
private val singleParamCapturingRx = """(?i)\s*(IN|OUT)\s+(\w+)\s+(.+)\s*""".r // used to break up params from ^^
// 1--1 2------2 3--3 4---4
// 1 - case insensitive matching
// 2 - capturing-group #1 IN/OUT param
// 3 - capturing-group #2 for param name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ class PgFunctionFileParserTest extends AnyFlatSpec with Matchers {

}

it should "parse multi-word IN parameter type" in {
val functionString =
"""/* comment here and there **/
|-- owner:
| owner_user123
|-- database: eXample_db ( )
|CREATE or REPLACE FUNCTION my_schema1.public_functionX(
| IN param_name TIMESTAMP WITH TIME ZONE
|) RETURNS record AS
|$$
|-------------------------------------------------------------------------------
|--""".stripMargin

PgFunctionFileParser.parseSource(functionString).head shouldBe FunctionFromSource(
fnName = FunctionName("public_functionX"),
paramTypes = Seq(FunctionArgumentType("TIMESTAMP WITH TIME ZONE")),
owner = UserName("owner_user123"),
users = Set.empty,
schema = SchemaName("my_schema1"),
database = DatabaseName("eXample_db"),
sqlBody = functionString
)
}

it should "parse example function example file" in {
val testFileUri = getClass.getClassLoader.getResource("public_function_example.sql").toURI

Expand Down