|
14 | 14 | import com.orientechnologies.orient.core.id.ORID; |
15 | 15 | import com.orientechnologies.orient.core.id.ORecordId; |
16 | 16 | import com.orientechnologies.orient.core.metadata.schema.OClass; |
| 17 | +import com.orientechnologies.orient.core.metadata.schema.OClass.INDEX_TYPE; |
17 | 18 | import com.orientechnologies.orient.core.metadata.schema.OProperty; |
18 | 19 | import com.orientechnologies.orient.core.metadata.schema.OSchema; |
19 | 20 | import com.orientechnologies.orient.core.metadata.schema.OType; |
@@ -410,6 +411,66 @@ public void testSelectOrderWithProjections2() { |
410 | 411 | result.close(); |
411 | 412 | } |
412 | 413 |
|
| 414 | + @Test |
| 415 | + public void testSelectOrderLinkSetIndex() { |
| 416 | + String className = "testSelectOrderLinkSetIndex"; |
| 417 | + OClass c1 = db.getMetadata().getSchema().createClass(className); |
| 418 | + c1.createProperty("Name", OType.STRING); |
| 419 | + String className2 = "testSelectOrderLinkSetIndexLink"; |
| 420 | + OClass c2 = db.getMetadata().getSchema().createClass(className2); |
| 421 | + OProperty p = c2.createProperty("NativeState", OType.LINKSET, c1); |
| 422 | + p.createIndex(INDEX_TYPE.NOTUNIQUE); |
| 423 | + |
| 424 | + db.command("INSERT INTO " + className + " SET Name = 'M'").close(); |
| 425 | + ; |
| 426 | + db.command("INSERT INTO " + className + " SET Name = 'P'").close(); |
| 427 | + ; |
| 428 | + db.command("INSERT INTO " + className + " SET Name = 'G'").close(); |
| 429 | + ; |
| 430 | + |
| 431 | + db.command( |
| 432 | + "INSERT INTO " |
| 433 | + + className2 |
| 434 | + + " SET NativeState = (SELECT FROM " |
| 435 | + + className |
| 436 | + + " WHERE Name = 'M')") |
| 437 | + .close(); |
| 438 | + ; |
| 439 | + db.command( |
| 440 | + "INSERT INTO " |
| 441 | + + className2 |
| 442 | + + " SET NativeState = (SELECT FROM " |
| 443 | + + className |
| 444 | + + " WHERE Name = 'P')") |
| 445 | + .close(); |
| 446 | + ; |
| 447 | + db.command( |
| 448 | + "INSERT INTO " |
| 449 | + + className2 |
| 450 | + + " SET NativeState = (SELECT FROM " |
| 451 | + + className |
| 452 | + + " WHERE Name = 'G')") |
| 453 | + .close(); |
| 454 | + ; |
| 455 | + |
| 456 | + OResultSet result = |
| 457 | + db.query( |
| 458 | + "SELECT NativeState, NativeState[0].Name AS _NativeState_Name \n" |
| 459 | + + "FROM " |
| 460 | + + className2 |
| 461 | + + " WHERE NativeState IN (SELECT FROM " |
| 462 | + + className |
| 463 | + + " WHERE Name IN ['M','P','G']) \n" |
| 464 | + + "ORDER BY NativeState[0].Name DESC"); |
| 465 | + printExecutionPlan(result); |
| 466 | + List<String> names = |
| 467 | + result.stream() |
| 468 | + .map((x) -> (String) x.getProperty("_NativeState_Name")) |
| 469 | + .collect(Collectors.toList()); |
| 470 | + assertEquals(Arrays.asList("P", "M", "G"), names); |
| 471 | + result.close(); |
| 472 | + } |
| 473 | + |
413 | 474 | @Test |
414 | 475 | public void testSelectFullScanWithFilter1() { |
415 | 476 | String className = "testSelectFullScanWithFilter1"; |
|
0 commit comments