leehaut commented on code in PR #9194:
URL: https://github.com/apache/hop/pull/9194#discussion_r4436074858
##########
plugins/actions/truncatetables/src/main/java/org/apache/hop/workflow/actions/truncatetables/ActionTruncateTables.java:
##########
@@ -153,81 +147,98 @@ public Result execute(Result previousResult, int nr) {
return result;
}
}
- if (connection != null) {
-
- try (Database db =
- new Database(
- this, this, getParentWorkflowMeta().findDatabase(connection,
getVariables()))) {
- db.connect();
- if (argFromPrevious && rows != null) { // Copy the input row to the
(command line) arguments
-
- for (int iteration = 0;
- iteration < rows.size() && !parentWorkflow.isStopped() &&
continueProcess;
- iteration++) {
- resultRow = rows.get(iteration);
-
- // Get values from previous result
- String tableNamePrevious = resultRow.getString(0, null);
- String schemaNamePrevious = resultRow.getString(1, null);
-
- if (!Utils.isEmpty(tableNamePrevious)) {
- if (isDetailed()) {
- logDetailed(
- BaseMessages.getString(
- PKG,
- "ActionTruncateTables.ProcessingRow",
- tableNamePrevious,
- schemaNamePrevious));
- }
-
- // let's truncate table
- if (truncateTables(tableNamePrevious, schemaNamePrevious, db)) {
- updateSuccess();
+ String realConnection = resolve(connection);
+ if (Utils.isEmpty(realConnection)) {
+ updateErrors();
+ logError(BaseMessages.getString(PKG,
"ActionTruncateTables.NoDbConnection"));
+ } else {
+ DatabaseMeta databaseMeta =
+ getParentWorkflowMeta() == null
+ ? null
+ : getParentWorkflowMeta().findDatabase(realConnection,
getVariables());
Review Comment:
Thanks — fixed. findDatabase() is back inside the try/catch with
db.connect(), null check kept, and a unit test covers the HopRuntimeException
path. Pushed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]