Skip to content

Commit

Permalink
#1763 fix createEdgeStep and reinforce tests (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrank authored Jan 15, 2025
1 parent f086acb commit 8f25690
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public Result next(final Object[] properties) {
for (Edge existingEdge : context.getDatabase().getGraphEngine()
.getEdges((VertexInternal) currentFrom, Vertex.DIRECTION.OUT, targetClass.getStringValue())) {

if (existingEdge.getOut().equals(currentTo)) {
if (existingEdge.getIn().equals(currentTo)) {
currentTo = null;
currentBatch++;
return new UpdatableResult(existingEdge.modify());
Expand Down
9 changes: 1 addition & 8 deletions engine/src/test/java/com/arcadedb/graph/BasicGraphTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,7 @@ public void edgeUnivocitySQL() {
// EXPECTED
}

try {
database.transaction(
() -> database.command("sql", "create edge OnlyOneBetweenVertices from ? to ? IF NOT EXISTS", v1[0], v2[0]));
fail("");
} catch (final DuplicatedKeyException ex) {
// EXPECTED
}

database.transaction(() -> database.command("sql", "create edge OnlyOneBetweenVertices from ? to ? IF NOT EXISTS", v1[0], v2[0]));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ void createEdgeIfNotExists() {
""");
});

database.transaction(() -> {
final ResultSet rs = database.query("SQL", """
select from vex
""");
assertThat(rs.stream().count()).isEqualTo(3);
});
// CREATE EDGES FROM #1:0 TO [#1:1,#1:2]
database.transaction(() -> {
final ResultSet rs = database.command("sql", """
Expand All @@ -131,18 +125,31 @@ void createEdgeIfNotExists() {
final ResultSet rs = database.command("sql", """
CREATE EDGE edg FROM #1:0 TO [#1:1,#1:2] IF NOT EXISTS
""");
assertThat(rs.hasNext()).isTrue();
assertThat(rs.stream().count()).isEqualTo(2);
});

// CHECK THAT TOTAL EDGES ARE STILL 2
database.transaction(() -> {
final ResultSet rs = database.query("SQL", """
select from edg
""");
assertThat(rs.stream().count()).isEqualTo(2);
});
// CREATE AGAIN (should create 1 edge)
database.transaction(() -> {
final ResultSet rs = database.command("sql", """
CREATE EDGE edg FROM #1:0 TO [#1:1,#1:2,#1:0] IF NOT EXISTS
""");
assertThat(rs.hasNext()).isTrue();
assertThat(rs.stream().count()).isEqualTo(3);
});

// CHECK THAT TOTAL EDGES ARE STILL 3
database.transaction(() -> {
final ResultSet rs = database.query("SQL", """
select from edg
""");
assertThat(rs.stream().count()).isEqualTo(3);
});


}
}

0 comments on commit 8f25690

Please sign in to comment.