This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b917560d6d Fix the display of current database during switching 
between table and tree model
5b917560d6d is described below

commit 5b917560d6d35b25fd90b8c0e1368fad1b61333b
Author: Li Yu Heng <[email protected]>
AuthorDate: Thu Mar 13 09:07:57 2025 +0800

    Fix the display of current database during switching between table and tree 
model
---
 .../main/java/org/apache/iotdb/cli/AbstractCli.java  | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
index 248203098a1..2ea63dbaaf0 100644
--- a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
+++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java
@@ -569,7 +569,8 @@ public abstract class AbstractCli {
       ZoneId zoneId = ZoneId.of(connection.getTimeZone());
       statement.setFetchSize(fetchSize);
       boolean hasResultSet = statement.execute(cmd.trim());
-      
updateUsingDatabaseIfNecessary(connection.getParams().getDb().orElse(null));
+      updateSqlDialectAndUsingDatabase(
+          connection.getParams().getSqlDialect(), 
connection.getParams().getDb().orElse(null));
       if (hasResultSet) {
         // print the result
         try (ResultSet resultSet = statement.getResultSet()) {
@@ -890,13 +891,18 @@ public abstract class AbstractCli {
     return true;
   }
 
-  private static void updateUsingDatabaseIfNecessary(String database) {
-    if (!Objects.equals(usingDatabase, database)) {
-      usingDatabase = database;
+  private static void updateSqlDialectAndUsingDatabase(
+      String sqlDialectOfConnection, String databaseOfConnection) {
+    boolean needUpdateCliPrefix =
+        !Objects.equals(sqlDialect, sqlDialectOfConnection)
+            || !Objects.equals(usingDatabase, databaseOfConnection);
+    sqlDialect = sqlDialectOfConnection;
+    usingDatabase = databaseOfConnection;
+    if (needUpdateCliPrefix) {
+      cliPrefix = IOTDB;
       if (sqlDialect != null && 
Model.TABLE.name().equals(sqlDialect.toUpperCase())) {
-        cliPrefix = IOTDB;
-        if (database != null) {
-          cliPrefix += ":" + database;
+        if (databaseOfConnection != null) {
+          cliPrefix += ":" + databaseOfConnection;
         }
       }
     }

Reply via email to