use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testFilterAndOrderBy.
@Test
public void testFilterAndOrderBy() {
// issue http://www.prjhub.com/#/issues/6199
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT FROM FilterAndOrderByTest WHERE active = true ORDER BY dc DESC");
List<ODocument> results = db.query(sql);
assertEquals(results.size(), 3);
Calendar cal = new GregorianCalendar();
Date date = results.get(0).field("dc");
cal.setTime(date);
assertEquals(cal.get(Calendar.YEAR), 2016);
date = results.get(1).field("dc");
cal.setTime(date);
assertEquals(cal.get(Calendar.YEAR), 2010);
date = results.get(2).field("dc");
cal.setTime(date);
assertEquals(cal.get(Calendar.YEAR), 2009);
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testSkipZeroOrdered.
@Test
public void testSkipZeroOrdered() {
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT from alphabet ORDER BY letter SKIP 0");
List<ODocument> results = db.query(sql);
assertEquals(26, results.size());
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testMatchesWithQuotes.
@Test
public void testMatchesWithQuotes() {
// issue #5229
String pattern = Pattern.quote("adm") + ".*";
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT FROM matchesstuff WHERE (name matches ?)");
List<ODocument> results = db.query(sql, pattern);
assertEquals(results.size(), 1);
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLSelectTest method testBasicQueryOrdered.
// /*** from issue #2743
@Test
public void testBasicQueryOrdered() {
OSQLSynchQuery sql = new OSQLSynchQuery("SELECT from alphabet ORDER BY letter");
List<ODocument> results = db.query(sql);
assertEquals(26, results.size());
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreateSequenceTest method testStartIncrement.
@Test
public void testStartIncrement() {
db.command(new OCommandSQL("CREATE SEQUENCE SequenceStartIncrement TYPE ORDERED START 3 INCREMENT 10")).execute();
List<ODocument> results = db.query(new OSQLSynchQuery("select sequence('SequenceStartIncrement').next() as val"));
assertEquals(results.size(), 1);
for (ODocument result : results) {
assertEquals(result.field("val"), 13L);
}
results = db.query(new OSQLSynchQuery("select sequence('SequenceStartIncrement').next() as val"));
assertEquals(results.size(), 1);
for (ODocument result : results) {
assertEquals(result.field("val"), 23L);
}
results = db.query(new OSQLSynchQuery("select sequence('SequenceStartIncrement').next() as val"));
assertEquals(results.size(), 1);
for (ODocument result : results) {
assertEquals(result.field("val"), 33L);
}
}
Aggregations