Search in sources :

Example 46 with OSQLSynchQuery

use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.

the class TransactionConsistencyTest method deletesWithinTransactionArentWorking.

@Test
public void deletesWithinTransactionArentWorking() throws IOException {
    OrientGraph graph = new OrientGraph(url);
    graph.setUseLightweightEdges(false);
    try {
        if (graph.getVertexType("Foo") == null)
            graph.createVertexType("Foo");
        if (graph.getVertexType("Bar") == null)
            graph.createVertexType("Bar");
        if (graph.getVertexType("Sees") == null)
            graph.createEdgeType("Sees");
        // Commenting out the transaction will result in the test succeeding.
        ODocument foo = graph.addVertex("class:Foo", "prop", "test1").getRecord();
        // Comment out these two lines and the test will succeed. The issue appears to be related to an edge
        // connecting a deleted vertex during a transaction
        ODocument bar = graph.addVertex("class:Bar", "prop", "test1").getRecord();
        ODocument sees = graph.addEdge(null, graph.getVertex(foo), graph.getVertex(bar), "Sees").getRecord();
        graph.commit();
        List<ODocument> foos = graph.getRawGraph().query(new OSQLSynchQuery("select * from Foo"));
        Assert.assertEquals(foos.size(), 1);
        graph.removeVertex(graph.getVertex(foos.get(0)));
    } finally {
        graph.shutdown();
    }
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test) DatabaseAbstractTest(com.orientechnologies.DatabaseAbstractTest)

Example 47 with OSQLSynchQuery

use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.

the class TraverseTest method traverseAndFilterByAttributeThatContainsDotInValue.

@Test
public void traverseAndFilterByAttributeThatContainsDotInValue() {
    // issue #4952
    List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("select from ( traverse out_married, in[attributeWithDotValue = 'a.b']  from " + tomCruise.getIdentity() + ")")).execute();
    Assert.assertTrue(result1.size() > 0);
    boolean found = false;
    for (ODocument doc : result1) {
        String name = doc.field("name");
        if ("Nicole Kidman".equals(name)) {
            found = true;
            break;
        }
    }
    Assert.assertTrue(found);
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 48 with OSQLSynchQuery

use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.

the class TraverseTest method traverseAndCheckReturn.

@Test
public void traverseAndCheckReturn() {
    try {
        String q = "traverse in('married')  from " + nicoleKidman.getIdentity() + "";
        ODatabaseDocumentTx db = database.copy();
        ODatabaseRecordThreadLocal.INSTANCE.set(db);
        List<Object> result1 = db.command(new OSQLSynchQuery<ODocument>(q)).execute();
        Assert.assertEquals(result1.size(), 2);
        boolean found = false;
        Integer i = 0;
        for (Object doc : result1) {
            Assert.assertTrue(doc instanceof ODocument);
        }
    } finally {
        ODatabaseRecordThreadLocal.INSTANCE.set(database);
    }
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 49 with OSQLSynchQuery

use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.

the class TraverseTest method traverseSelectIterable.

@Test
public void traverseSelectIterable() {
    int cycles = 0;
    for (OIdentifiable id : new OSQLSynchQuery<ODocument>("select from ( traverse * from Movie while $depth < 2 )")) {
        cycles++;
    }
    Assert.assertTrue(cycles > 0);
}
Also used : OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Example 50 with OSQLSynchQuery

use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.

the class TraverseTest method traverseAndCheckDepthInSelect.

@Test
public void traverseAndCheckDepthInSelect() {
    List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("select *, $depth as d from ( traverse out_married  from " + tomCruise.getIdentity() + " while $depth < 2)")).execute();
    Assert.assertEquals(result1.size(), 2);
    boolean found = false;
    Integer i = 0;
    for (ODocument doc : result1) {
        Integer depth = doc.field("d");
        Assert.assertEquals(depth, i++);
    }
}
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