Skip to content

Commit

Permalink
test: add test for cover issue #10303
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Nov 25, 2024
1 parent a1cdfd1 commit ac33017
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.orientechnologies.orient.core.sql.executor;

import static com.orientechnologies.orient.core.sql.executor.ExecutionPlanPrintUtils.printExecutionPlan;
import static org.junit.Assert.assertEquals;

import com.orientechnologies.BaseMemoryDatabase;
import com.orientechnologies.common.concur.OTimeoutException;
Expand Down Expand Up @@ -4794,4 +4795,45 @@ public void variableProjectionTraverse() {
}
}
}

@Test
public void testContainsParamInMapInBrackets() {
OSchema schema = db.getMetadata().getSchema();
db.command("CREATE CLASS Entity EXTENDS V");
db.command("CREATE CLASS RelatedEntity EXTENDS V");
db.command("CREATE CLASS ConnectorEdge EXTENDS E");

OVertex entity1 = db.newVertex("Entity");
entity1.setProperty("name", "Entity1");
db.save(entity1);

OVertex entity2 = db.newVertex("Entity");
entity2.setProperty("name", "Entity2");
db.save(entity2);

OVertex relatedEntity1 = db.newVertex("RelatedEntity");
relatedEntity1.setProperty("name", "RelatedEntity1");
db.save(relatedEntity1);

OVertex relatedEntity2 = db.newVertex("RelatedEntity");
relatedEntity2.setProperty("name", "RelatedEntity2");
db.save(relatedEntity2);

final OEdge connectorEdge11 = entity1.addEdge(relatedEntity1, "ConnectorEdge");
final OEdge connectorEdge12 = entity1.addEdge(relatedEntity2, "ConnectorEdge");
final OEdge connectorEdge21 = entity2.addEdge(relatedEntity1, "ConnectorEdge");
db.save(connectorEdge11);
db.save(connectorEdge12);
db.save(connectorEdge21);

String query =
"SELECT * as result FROM Entity "
+ " WHERE out('ConnectorEdge') contains [:relatedEntity2] ";
try (OResultSet rs = db.query(query, Map.of("relatedEntity2", relatedEntity2.getIdentity()))) {
final List<OResult> results = rs.stream().toList();
assertEquals(1, results.size());
final ORID resultId = results.get(0).getIdentity().orElseThrow();
assertEquals(entity1.getIdentity(), resultId);
}
}
}

0 comments on commit ac33017

Please sign in to comment.