From 242d31ab0b4982a61ee2f1c032cadb20929a6903 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 11 Sep 2024 09:16:43 +0200 Subject: [PATCH 1/5] #33: Make execution of function without verification easier --- .../scala/za/co/absa/db/balta/classes/DBFunction.scala | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala index 8f39e50..e511a81 100644 --- a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala +++ b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala @@ -45,6 +45,14 @@ sealed abstract class DBFunction private(functionName: String, s"SELECT * FROM $functionName($paramsLine) $orderBy" } + /** + * Executes the function. + * @param connection - the database connection + */ + def execute()(implicit connection: DBConnection): Unit = { + execute("")(_ => Unit) + } + /** * Executes the function and verifies the result via the verify function. * From 10801f636590214be543dd757fe98b9a1ca3a39f Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 11 Sep 2024 09:26:48 +0200 Subject: [PATCH 2/5] * new overloaded version of `DBFunction.execute` added --- .../src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala index e511a81..4aa4e7f 100644 --- a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala +++ b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala @@ -50,7 +50,7 @@ sealed abstract class DBFunction private(functionName: String, * @param connection - the database connection */ def execute()(implicit connection: DBConnection): Unit = { - execute("")(_ => Unit) + execute("")(_ => ()) } /** From 4484c57aa5b5f14ee4b0d87322415511f303e567 Mon Sep 17 00:00:00 2001 From: David Benedeki Date: Wed, 11 Sep 2024 11:39:35 +0200 Subject: [PATCH 3/5] * the new `execute` renamed to `perform` * new function `getResult` which returns the list of function outputs --- .../za/co/absa/db/balta/classes/DBFunction.scala | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala index 4aa4e7f..0db007c 100644 --- a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala +++ b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala @@ -46,13 +46,23 @@ sealed abstract class DBFunction private(functionName: String, } /** - * Executes the function. + * Executes the function without caring about the result. The goal is the side-effect of the function. * @param connection - the database connection */ - def execute()(implicit connection: DBConnection): Unit = { + def perform()(implicit connection: DBConnection): Unit = { execute("")(_ => ()) } + /** + * Executes the function without any verification proceudre. It instantiate the function result(s) and return them in + * a list. + * @param orderBy - the clause how to order the function result, if empty, default ordering is preserved + * @param connection - the database connection + */ + def getResult(orderBy: String = "")(implicit connection: DBConnection): List[QueryResultRow] = { + execute("")(_.toList) + } + /** * Executes the function and verifies the result via the verify function. * From 789b92cf69c20f3874b24bf9cb7e587b5bdcc706 Mon Sep 17 00:00:00 2001 From: David Benedeki <14905969+benedeki@users.noreply.github.com> Date: Wed, 11 Sep 2024 11:53:41 +0200 Subject: [PATCH 4/5] Update balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala Co-authored-by: miroslavpojer --- .../src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala index 0db007c..9dbb541 100644 --- a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala +++ b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala @@ -54,7 +54,7 @@ sealed abstract class DBFunction private(functionName: String, } /** - * Executes the function without any verification proceudre. It instantiate the function result(s) and return them in + * Executes the function without any verification procedure. It instantiates the function result(s) and returns them in * a list. * @param orderBy - the clause how to order the function result, if empty, default ordering is preserved * @param connection - the database connection From e923c4237df868ce017d176b8af8a65dc77056ac Mon Sep 17 00:00:00 2001 From: David Benedeki <14905969+benedeki@users.noreply.github.com> Date: Wed, 11 Sep 2024 11:57:08 +0200 Subject: [PATCH 5/5] Update balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala Co-authored-by: miroslavpojer --- .../src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala index 9dbb541..b537e69 100644 --- a/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala +++ b/balta/src/main/scala/za/co/absa/db/balta/classes/DBFunction.scala @@ -60,7 +60,7 @@ sealed abstract class DBFunction private(functionName: String, * @param connection - the database connection */ def getResult(orderBy: String = "")(implicit connection: DBConnection): List[QueryResultRow] = { - execute("")(_.toList) + execute(orderBy)(_.toList) } /**