Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit bb3d239

Browse files
committed
Fix case sensitivity of system database name
Use case insensitive comparison when checking if we are on the system database to decide which ping query to use.
1 parent 90cf424 commit bb3d239

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellMultiDatabaseIntegrationTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public void switchingToSystemDatabaseWorks() throws CommandException {
6060
assertOnSystemDB();
6161
}
6262

63+
@Test
64+
public void switchingToSystemDatabaseIsNotCaseSensitive() throws CommandException {
65+
useCommand.execute("SyStEm");
66+
67+
assertThat(linePrinter.output(), is(""));
68+
assertOnSystemDB();
69+
}
70+
6371
@Test
6472
public void switchingToSystemDatabaseAndBackToNeo4jWorks() throws CommandException {
6573
useCommand.execute(SYSTEM_DB_NAME);

cypher-shell/src/main/java/org/neo4j/shell/state/BoltStateHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private void reconnect(boolean keepBookmark) {
162162
};
163163
session = driver.session(sessionArgs.andThen(sessionOptionalArgs));
164164

165-
String query = activeDatabaseNameAsSetByUser.equals(SYSTEM_DB_NAME) ? "SHOW DATABASES" : "RETURN 1";
165+
String query = activeDatabaseNameAsSetByUser.compareToIgnoreCase(SYSTEM_DB_NAME) == 0 ? "SHOW DATABASES" : "RETURN 1";
166166

167167
resetActualDbName(); // Set this to null first in case run throws an exception
168168
StatementResult run = session.run(query);

0 commit comments

Comments
 (0)