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();
}
}
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);
}
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);
}
}
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);
}
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++);
}
}
Aggregations