Skip to content

Commit de01d1f

Browse files
tomasnybergsimonthuresson
authored andcommitted
Fixes IS CONNECTED concatenate bug in formatter (neo4j#401)
1 parent f5553ac commit de01d1f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/language-support/src/formatting/formatting.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,8 @@ export class TreePrintVisitor extends CypherCmdParserVisitor<void> {
768768
) => {
769769
this.visitIfNotNull(ctx.variable());
770770
this.visitIfNotNull(ctx.labelExpression());
771-
if (ctx instanceof RelationshipPatternContext) {
772-
this.visitIfNotNull(ctx.pathLength());
771+
if (ctx instanceof RelationshipPatternContext && ctx.pathLength()) {
772+
this.visit(ctx.pathLength());
773773
this.concatenate();
774774
}
775775
this.visitIfNotNull(ctx.properties());

packages/language-support/src/tests/formatting/edgecases.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -617,4 +617,11 @@ FOREACH (item IN items |
617617
RETURN n`;
618618
verifyFormatting(query, expected);
619619
});
620+
621+
test('relation with IS CONNECTED should not concatenate to ISCONNECTED', () => {
622+
const query = `MATCH (n)-[IS CONNECTED]->(m)
623+
RETURN n, m`;
624+
const expected = query;
625+
verifyFormatting(query, expected);
626+
});
620627
});

0 commit comments

Comments
 (0)