use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testDistinctLimit.
@Test
public void testDistinctLimit() {
OSQLSynchQuery sql = new OSQLSynchQuery("select distinct(name) from DistinctLimit limit 1");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 1);
sql = new OSQLSynchQuery("select distinct(name) from DistinctLimit limit 2");
results = db.query(sql);
assertEquals(results.size(), 2);
sql = new OSQLSynchQuery("select distinct(name) from DistinctLimit limit 3");
results = db.query(sql);
assertEquals(results.size(), 2);
sql = new OSQLSynchQuery("select distinct(name) from DistinctLimit limit -1");
results = db.query(sql);
assertEquals(results.size(), 2);
}
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 testSkipAndLimitMinusOneOrdered.
@Test
public void testSkipAndLimitMinusOneOrdered() {
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT from alphabet ORDER BY letter SKIP 7 LIMIT -1");
List<ODocument> results = db.query(sql);
assertEquals(19, results.size());
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testNullProjection.
@Test
public void testNullProjection() {
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT 1 AS integer, 'Test' AS string, NULL AS nothing, [] AS array, {} AS object");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 1);
ODocument doc = results.get(0);
assertEquals(doc.field("integer"), 1);
assertEquals(doc.field("string"), "Test");
assertNull(doc.field("nothing"));
boolean nullFound = false;
for (String s : doc.fieldNames()) {
if (s.equals("nothing")) {
nullFound = true;
break;
}
}
assertTrue(nullFound);
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testMassiveOrderAscSkipLimit.
@Test
public void testMassiveOrderAscSkipLimit() {
int skip = 1000;
OSQLSynchQuery sql0 = new OSQLSynchQuery("SELECT from MassiveOrderSkipLimit order by nnum asc limit " + skip);
List<ODocument> results0 = db.query(sql0);
assertEquals(results0.size(), 1000);
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