samuelwillyanto1 commented on code in PR #8778:
URL: https://github.com/apache/hop/pull/8778#discussion_r4231969839


##########
plugins/actions/truncatetables/src/main/java/org/apache/hop/workflow/actions/truncatetables/ActionTruncateTablesDialog.java:
##########
@@ -302,26 +307,64 @@ private void ok() {
   }
 
   private void getTableName() {
-    DatabaseMeta databaseMeta = 
getWorkflowMeta().findDatabase(wConnection.getText(), variables);
+    String connectionName = wConnection.getText();
+    if (Utils.isEmpty(connectionName)) {
+      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
+      mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
+      mb.setMessage(BaseMessages.getString(PKG, 
"ActionTruncateTables.NoDbConnection"));
+      mb.open();
+      return;
+    }
+
+    DatabaseMeta databaseMeta = getWorkflowMeta().findDatabase(connectionName, 
variables);
     if (databaseMeta != null) {
 
       try (Database database = new Database(loggingObject, variables, 
databaseMeta)) {
         database.connect();
-        String[] tableNames = database.getTablenames();
-        Arrays.sort(tableNames);
+        Map<String, Collection<String>> tableMap = database.getTableMap();
+        List<String> displayList = new ArrayList<>();
+        List<String[]> schemaTableList = new ArrayList<>();
+
+        if (tableMap != null && !tableMap.isEmpty()) {
+          List<String> schemas = new ArrayList<>(tableMap.keySet());
+          Collections.sort(schemas, String.CASE_INSENSITIVE_ORDER);

Review Comment:
   Done. Applied Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER) to both 
schema and table sorting to safely support schema-less databases like SQLite, 
and broadened the catch block to catch (Exception e).



-- 
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]

Reply via email to