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

Commit d8b44f7

Browse files
committed
support for colon form of :param command.
1 parent 2e01e7b commit d8b44f7

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void commitScenario() throws CommandException {
162162
}
163163

164164
@Test
165-
public void setAndListVariables() throws CommandException {
165+
public void paramsAndListVariables() throws CommandException {
166166
assertTrue(shell.getAll().isEmpty());
167167

168168
long randomLong = System.currentTimeMillis();

cypher-shell/src/main/java/org/neo4j/shell/commands/Param.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
public class Param implements Command {
1818
// Match arguments such as "(key) (value with possible spaces)" where key and value are any strings
19-
private static final Pattern argPattern = Pattern.compile("^\\s*(?<key>[^\\s]+)\\s+(?<value>.+)$");
19+
private static final Pattern argPattern = Pattern.compile("^\\s*(?<key>.+?):?\\s+(?<value>.+)$");
2020
public static final String COMMAND_NAME = ":param";
2121
private final VariableHolder variableHolder;
2222

cypher-shell/src/test/java/org/neo4j/shell/commands/ParamTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,34 @@ public void setValue() throws CommandException {
5050
verify(mockShell).set("bob", "9");
5151
}
5252

53+
@Test
54+
public void setValueWithSpecialCharacters() throws CommandException {
55+
cmd.execute("bob# 9");
56+
57+
verify(mockShell).set("bob#", "9");
58+
}
59+
5360
@Test
5461
public void shouldNotSplitOnSpace() throws CommandException {
5562
cmd.execute("bob 'one two'");
5663
verify(mockShell).set("bob", "'one two'");
5764
}
5865

66+
@Test
67+
public void shouldAcceptColonFormOfParams() throws CommandException {
68+
cmd.execute("bob: one");
69+
verify(mockShell).set("bob", "one");
70+
}
71+
72+
@Test
73+
public void shouldAcceptForTwoColonsFormOfParams() throws CommandException {
74+
cmd.execute("bob:: one");
75+
verify(mockShell).set("bob:", "one");
76+
77+
cmd.execute("t:om two");
78+
verify(mockShell).set("t:om", "two");
79+
}
80+
5981
@Test
6082
public void shouldNotExecuteEscapedCypher() throws CommandException {
6183
cmd.execute("bob \"RETURN 5 as bob\"");

0 commit comments

Comments
 (0)