Skip to content

Commit

Permalink
fix: $ must be escaped in future Cypher versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-simons committed Dec 12, 2024
1 parent fd0db21 commit cdf8b41
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 41 deletions.
37 changes: 0 additions & 37 deletions neo4j-cypher-dsl-parser/src/main/java/module-info.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ public Statement showAliases(InputPosition p, DatabaseName aliasName, Clause yie

@Override
public void addDeprecatedIdentifierUnicodeNotification(InputPosition p, Character character, String identifier) {
throw new UnsupportedOperationException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class HandleNewMethods {
@ParameterizedTest
@ValueSource(strings = { "showAliases", "createLocalDatabaseAlias", "createRemoteDatabaseAlias",
"alterLocalDatabaseAlias", "alterRemoteDatabaseAlias", "fixedPathQuantifier",
"useGraph", "setOwnPassword", "addDeprecatedIdentifierUnicodeNotification",
"useGraph", "setOwnPassword",
"showAllPrivileges", "showRolePrivileges", "showUserPrivileges", "createDatabase",
"createCompositeDatabase", "dropDatabase",
"showDatabase", "startDatabase", "stopDatabase", "createUser", "dropUser", "alterUser", "renameUser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,4 +838,9 @@ void optionalSubquery() {
CypherParser.parse("MATCH (n) OPTIONAL CALL() {MATCH (m)}"))
.withMessage("Cannot render optional subquery clause");
}

@Test
void unescapedThings() {
assertThat(CypherParser.parse("RETURN 1 AS v$_id").getCypher()).isEqualTo("RETURN 1 AS `v$_id`");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,16 @@ private static boolean isIdentifier(CharSequence name) {

String id = name.toString();
int cp = id.codePointAt(0);
if (!Character.isJavaIdentifierStart(cp)) {
if (!Character.isJavaIdentifierStart(cp) || '$' == cp) {
return false;
}
for (int i = Character.charCount(cp); i < id.length(); i += Character.charCount(cp)) {
cp = id.codePointAt(i);
if (!Character.isJavaIdentifierPart(cp)) {
if (!Character.isJavaIdentifierPart(cp) || '$' == cp) {
return false;
}
}

return true;
}

Expand Down

0 comments on commit cdf8b41

Please sign in to comment.