Skip to content

Commit b20e34a

Browse files
committed
test: add test to verify use of range operations with composite indexes, issue #10456
1 parent c5d9e91 commit b20e34a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

core/src/test/java/com/orientechnologies/orient/core/sql/executor/OSelectStatementExecutionTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,31 @@ public void testFetchFromClassWithIndexes15() {
16351635
result.close();
16361636
}
16371637

1638+
@Test
1639+
public void testFetchFromCompsiteIndex() {
1640+
String className = "testFetchFromClassCompositeIndex";
1641+
OClass clazz = db.getMetadata().getSchema().createClass(className);
1642+
clazz.createProperty("first", OType.LONG);
1643+
clazz.createProperty("second", OType.LONG);
1644+
clazz.createIndex(className + ".first_second", OClass.INDEX_TYPE.NOTUNIQUE, "second", "first");
1645+
1646+
for (int i = 0; i < 10; i++) {
1647+
ODocument doc = db.newInstance(className);
1648+
doc.setProperty("first", 99);
1649+
doc.setProperty("second", 5 + i);
1650+
db.save(doc);
1651+
}
1652+
1653+
OResultSet result =
1654+
db.query("select from " + className + " where second <=10 and first = 99 ");
1655+
printExecutionPlan(result);
1656+
Assert.assertEquals(result.stream().count(), 6);
1657+
OSelectExecutionPlan plan = (OSelectExecutionPlan) result.getExecutionPlan().get();
1658+
Assert.assertEquals(
1659+
1, plan.getSteps().stream().filter(step -> step instanceof FetchFromIndexStep).count());
1660+
result.close();
1661+
}
1662+
16381663
@Test
16391664
public void testFetchFromClassWithHashIndexes1() {
16401665
String className = "testFetchFromClassWithHashIndexes1";

0 commit comments

Comments
 (0)