Skip to content

Commit 5b91756

Browse files
Fix the display of current database during switching between table and tree model
1 parent b2bacd3 commit 5b91756

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

iotdb-client/cli/src/main/java/org/apache/iotdb/cli/AbstractCli.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ private static int executeQuery(CliContext ctx, IoTDBConnection connection, Stri
569569
ZoneId zoneId = ZoneId.of(connection.getTimeZone());
570570
statement.setFetchSize(fetchSize);
571571
boolean hasResultSet = statement.execute(cmd.trim());
572-
updateUsingDatabaseIfNecessary(connection.getParams().getDb().orElse(null));
572+
updateSqlDialectAndUsingDatabase(
573+
connection.getParams().getSqlDialect(), connection.getParams().getDb().orElse(null));
573574
if (hasResultSet) {
574575
// print the result
575576
try (ResultSet resultSet = statement.getResultSet()) {
@@ -890,13 +891,18 @@ static boolean processCommand(CliContext ctx, String s, IoTDBConnection connecti
890891
return true;
891892
}
892893

893-
private static void updateUsingDatabaseIfNecessary(String database) {
894-
if (!Objects.equals(usingDatabase, database)) {
895-
usingDatabase = database;
894+
private static void updateSqlDialectAndUsingDatabase(
895+
String sqlDialectOfConnection, String databaseOfConnection) {
896+
boolean needUpdateCliPrefix =
897+
!Objects.equals(sqlDialect, sqlDialectOfConnection)
898+
|| !Objects.equals(usingDatabase, databaseOfConnection);
899+
sqlDialect = sqlDialectOfConnection;
900+
usingDatabase = databaseOfConnection;
901+
if (needUpdateCliPrefix) {
902+
cliPrefix = IOTDB;
896903
if (sqlDialect != null && Model.TABLE.name().equals(sqlDialect.toUpperCase())) {
897-
cliPrefix = IOTDB;
898-
if (database != null) {
899-
cliPrefix += ":" + database;
904+
if (databaseOfConnection != null) {
905+
cliPrefix += ":" + databaseOfConnection;
900906
}
901907
}
902908
}

0 commit comments

Comments
 (0)