use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testLinkListSequence2.
@Test
public void testLinkListSequence2() {
OSQLSynchQuery sql = new OSQLSynchQuery("select expand(children[0].children.children) from LinkListSequence where name = 'root'");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 4);
for (ODocument result : results) {
String value = result.field("name");
assertEquals(value.length(), 5);
}
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testLimitOrdered.
@Test
public void testLimitOrdered() {
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT from alphabet ORDER BY letter LIMIT 9");
List<ODocument> results = db.query(sql);
assertEquals(9, results.size());
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testComplexFilterInSquareBrackets.
@Test
public void testComplexFilterInSquareBrackets() {
// issues #513 #5451
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT expand(collection[name = 'n1']) FROM ComplexFilterInSquareBrackets2");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 1);
assertEquals(results.iterator().next().field("name"), "n1");
sql = new OSQLSynchQuery("SELECT expand(collection[name = 'n1' and value = 1]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 1);
assertEquals(results.iterator().next().field("name"), "n1");
sql = new OSQLSynchQuery("SELECT expand(collection[name = 'n1' and value > 1]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 0);
sql = new OSQLSynchQuery("SELECT expand(collection[name = 'n1' or value = -1]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 2);
for (ODocument doc : results) {
assertTrue(doc.field("name").equals("n1") || doc.field("value").equals(-1));
}
sql = new OSQLSynchQuery("SELECT expand(collection[name = 'n1' and not value = 1]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 0);
sql = new OSQLSynchQuery("SELECT expand(collection[value < 0]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 1);
assertEquals(results.iterator().next().field("value"), -1);
sql = new OSQLSynchQuery("SELECT expand(collection[2]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 1);
sql = new OSQLSynchQuery("SELECT expand(collection[1-3]) FROM ComplexFilterInSquareBrackets2");
results = db.query(sql);
assertEquals(results.size(), 3);
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testDatesListContainsString.
@Test
public void testDatesListContainsString() {
// issue #3526
OSQLSynchQuery sql = new OSQLSynchQuery("select from OCommandExecutorSQLSelectTest_datesSet where foo contains '2015-10-21'");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 1);
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testMassiveOrderAscSkipLimitBatchSizePlusOne.
@Test
public void testMassiveOrderAscSkipLimitBatchSizePlusOne() {
int skip = OGlobalConfiguration.QUERY_SCAN_BATCH_SIZE.getValueAsInteger() + 1;
OSQLSynchQuery sql0 = new OSQLSynchQuery("SELECT from MassiveOrderSkipLimit order by nnum asc limit " + skip);
List<ODocument> results0 = db.query(sql0);
assertEquals(results0.size(), skip);
for (int i = 0; i < results0.size(); i++) {
ODocument doc = results0.get(i);
assertEquals(doc.field("nnum"), i);
}
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT from MassiveOrderSkipLimit order by nnum asc skip " + skip + " limit 5");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 5);
for (int i = 0; i < results.size(); i++) {
ODocument doc = results.get(i);
assertEquals(doc.field("nnum"), skip + i);
assertFalse(results0.contains(doc));
}
}
Aggregations