use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class TraverseTest method traverseAndFilterWithNamedParam.
@Test
public void traverseAndFilterWithNamedParam() {
// issue #5225
Map<String, Object> params = new HashMap<String, Object>();
params.put("param1", "a.b");
List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("select from (traverse out_married, in[attributeWithDotValue = :param1] from " + tomCruise.getIdentity() + ")")).execute(params);
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 traverseSQLMoviesOnlyDepth.
@Test
public void traverseSQLMoviesOnlyDepth() {
List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("select from ( traverse * from " + tomCruise.getIdentity() + " while $depth <= 1 ) where @class = 'Movie'")).execute();
Assert.assertTrue(result1.isEmpty());
List<ODocument> result2 = database.command(new OSQLSynchQuery<ODocument>("select from ( traverse * from " + tomCruise.getIdentity() + " while $depth <= 2 ) where @class = 'Movie'")).execute();
Assert.assertTrue(result2.size() > 0);
for (ODocument d : result2) {
Assert.assertEquals(d.getClassName(), "Movie");
}
List<ODocument> result3 = database.command(new OSQLSynchQuery<ODocument>("select from ( traverse * from " + tomCruise.getIdentity() + " ) where @class = 'Movie'")).execute();
Assert.assertTrue(result3.size() > 0);
Assert.assertTrue(result3.size() > result2.size());
for (ODocument d : result3) {
Assert.assertEquals(d.getClassName(), "Movie");
}
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class TraverseTest method traverseSQLMoviesOnly.
@Test
public void traverseSQLMoviesOnly() {
List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("select from ( traverse any() from Movie ) where @class = 'Movie'")).execute();
Assert.assertTrue(result1.size() > 0);
for (ODocument d : result1) {
Assert.assertEquals(d.getClassName(), "Movie");
}
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class TruncateClassTest method testTruncateVertexClassSubclassesWithIndex.
@Test
public void testTruncateVertexClassSubclassesWithIndex() {
database.command(new OCommandSQL("create class TestTruncateVertexClassSuperclassWithIndex")).execute();
database.command(new OCommandSQL("create property TestTruncateVertexClassSuperclassWithIndex.name STRING")).execute();
database.command(new OCommandSQL("create index TestTruncateVertexClassSuperclassWithIndex_index on TestTruncateVertexClassSuperclassWithIndex (name) NOTUNIQUE")).execute();
database.command(new OCommandSQL("create class TestTruncateVertexClassSubclassWithIndex extends TestTruncateVertexClassSuperclassWithIndex")).execute();
database.command(new OCommandSQL("insert into TestTruncateVertexClassSuperclassWithIndex set name = 'foo'")).execute();
database.command(new OCommandSQL("insert into TestTruncateVertexClassSubclassWithIndex set name = 'bar'")).execute();
List<?> result = database.query(new OSQLSynchQuery("select from index:TestTruncateVertexClassSuperclassWithIndex_index"));
Assert.assertEquals(result.size(), 2);
database.command(new OCommandSQL("truncate class TestTruncateVertexClassSubclassWithIndex")).execute();
result = database.query(new OSQLSynchQuery("select from index:TestTruncateVertexClassSuperclassWithIndex_index"));
Assert.assertEquals(result.size(), 1);
database.command(new OCommandSQL("truncate class TestTruncateVertexClassSuperclassWithIndex polymorphic")).execute();
result = database.query(new OSQLSynchQuery("select from index:TestTruncateVertexClassSuperclassWithIndex_index"));
Assert.assertEquals(result.size(), 0);
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class TruncateClassTest method testTruncateVertexClass.
@Test
public void testTruncateVertexClass() {
database.command(new OCommandSQL("create class TestTruncateVertexClass extends V")).execute();
database.command(new OCommandSQL("create vertex TestTruncateVertexClass set name = 'foo'")).execute();
try {
database.command(new OCommandSQL("truncate class TestTruncateVertexClass ")).execute();
Assert.fail();
} catch (Exception e) {
}
List<?> result = database.query(new OSQLSynchQuery("select from TestTruncateVertexClass"));
Assert.assertEquals(result.size(), 1);
database.command(new OCommandSQL("truncate class TestTruncateVertexClass unsafe")).execute();
result = database.query(new OSQLSynchQuery("select from TestTruncateVertexClass"));
Assert.assertEquals(result.size(), 0);
}
Aggregations