use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class BetweenConversionTest method testBetweenRightIncluded.
public void testBetweenRightIncluded() {
final String query = "select from BetweenConversionTest where a > 1 and a <= 3";
final List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 2);
List<Integer> values = new ArrayList<Integer>(Arrays.asList(2, 3));
for (ODocument document : result) {
Assert.assertTrue(values.remove((Integer) document.field("a")));
}
Assert.assertTrue(values.isEmpty());
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertEquals(explain.field("rangeQueryConvertedInBetween"), 1);
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class BetweenConversionTest method testBetweenRightLeftIncludedReverseOrder.
public void testBetweenRightLeftIncludedReverseOrder() {
final String query = "select from BetweenConversionTest where a <= 3 and a >= 1";
final List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 3);
List<Integer> values = new ArrayList<Integer>(Arrays.asList(1, 2, 3));
for (ODocument document : result) {
Assert.assertTrue(values.remove((Integer) document.field("a")));
}
Assert.assertTrue(values.isEmpty());
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertEquals(explain.field("rangeQueryConvertedInBetween"), 1);
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class BetweenConversionTest method testBetweenRightIncludedReverse.
public void testBetweenRightIncludedReverse() {
final String query = "select from BetweenConversionTest where a <= 3 and a > 1";
final List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 2);
List<Integer> values = new ArrayList<Integer>(Arrays.asList(2, 3));
for (ODocument document : result) {
Assert.assertTrue(values.remove((Integer) document.field("a")));
}
Assert.assertTrue(values.isEmpty());
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertEquals(explain.field("rangeQueryConvertedInBetween"), 1);
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class BetweenConversionTest method testBetweenIndex.
public void testBetweenIndex() {
final String query = "select from BetweenConversionTest where ai > 1 and ai < 3";
final List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 1);
List<Integer> values = new ArrayList<Integer>(Arrays.asList(2));
for (ODocument document : result) {
Assert.assertTrue(values.remove((Integer) document.field("ai")));
}
Assert.assertTrue(values.isEmpty());
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertEquals(explain.field("rangeQueryConvertedInBetween"), 1);
Assert.assertTrue(((Set<String>) explain.field("involvedIndexes")).contains("BetweenConversionTestIndex"));
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class BetweenConversionTest method testBetweenRightLeftIncludedBothFieldsRight.
public void testBetweenRightLeftIncludedBothFieldsRight() {
final String query = "select from BetweenConversionTest where a >= 1 and a <= ai";
final List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 9);
List<Integer> values = new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));
for (ODocument document : result) {
Assert.assertTrue(values.remove((Integer) document.field("a")));
}
Assert.assertTrue(values.isEmpty());
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertNull(explain.field("rangeQueryConvertedInBetween"));
}
Aggregations