Search in sources :

Example 96 with OSQLSynchQuery

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

Example 97 with OSQLSynchQuery

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

Example 98 with OSQLSynchQuery

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

Example 99 with OSQLSynchQuery

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

Example 100 with OSQLSynchQuery

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));
    }
}
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