Search in sources :

Example 86 with OSQLSynchQuery

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);
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 87 with OSQLSynchQuery

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());
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 88 with OSQLSynchQuery

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);
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 89 with OSQLSynchQuery

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());
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 90 with OSQLSynchQuery

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);
    }
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)506 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)426 Test (org.testng.annotations.Test)282 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)78 Test (org.junit.Test)60 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)57 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)47 ORID (com.orientechnologies.orient.core.id.ORID)34 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)31 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)22 List (java.util.List)21 HashMap (java.util.HashMap)20 ORecordId (com.orientechnologies.orient.core.id.ORecordId)19 Profile (com.orientechnologies.orient.test.domain.whiz.Profile)19 DatabaseAbstractTest (com.orientechnologies.DatabaseAbstractTest)16 Collection (java.util.Collection)15 OrientTest (com.orientechnologies.orient.test.database.base.OrientTest)13 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)13 Set (java.util.Set)12 OCommandScript (com.orientechnologies.orient.core.command.script.OCommandScript)11