diff --git a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java index 66eb02b3877..81ec2263a56 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java @@ -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; @@ -4797,4 +4798,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 results = rs.stream().toList(); + assertEquals(1, results.size()); + final ORID resultId = results.get(0).getIdentity().orElseThrow(); + assertEquals(entity1.getIdentity(), resultId); + } + } }