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());
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OChainIndexFetchTest method testFetchChaninedIndex.
@Test
public void testFetchChaninedIndex() {
OClass baseClass = db.getMetadata().getSchema().createClass("BaseClass");
OProperty propr = baseClass.createProperty("ref", OType.LINK);
OClass linkedClass = db.getMetadata().getSchema().createClass("LinkedClass");
OProperty id = linkedClass.createProperty("id", OType.STRING);
id.createIndex(INDEX_TYPE.UNIQUE);
propr.setLinkedClass(linkedClass);
propr.createIndex(INDEX_TYPE.NOTUNIQUE);
ODocument doc = new ODocument(linkedClass);
doc.field("id", "referred");
db.save(doc);
ODocument doc1 = new ODocument(baseClass);
doc1.field("ref", doc);
db.save(doc1);
List<ODocument> res = db.query(new OSQLSynchQuery(" select from BaseClass where ref.id ='wrong_referred' "));
assertEquals(0, res.size());
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class OCommandExecutorSQLUpdateTest method testUpdateAddOnNonExistingSet.
@Test
public void testUpdateAddOnNonExistingSet() throws Exception {
// issue #7194
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:testUpdateAddOnNonExistingSet");
db.create();
try {
db.command(new OCommandSQL("CREATE class Foo")).execute();
db.command(new OCommandSQL("CREATE property Foo.tags EMBEDDEDSET")).execute();
db.command(new OCommandSQL("insert into Foo set name = 'a'")).execute();
db.command(new OCommandSQL("update Foo add tags = 'foo'")).execute();
List<ODocument> result = db.query(new OSQLSynchQuery("SELECT FROM Foo"));
assertEquals(result.size(), 1);
ODocument doc = result.get(0);
Set tags = doc.field("tags");
assertEquals(tags.size(), 1);
assertTrue(tags.contains("foo"));
} finally {
db.drop();
}
}
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);
}
}
use of com.orientechnologies.orient.core.sql.query.OSQLSynchQuery in project orientdb by orientechnologies.
the class LuceneTransactionQueryTest method testRollback.
@Test
public void testRollback() {
ODocument doc = new ODocument("c1");
doc.field("p1", "abc");
db.begin();
db.save(doc);
String query = "select from C1 where p1 lucene \"abc\" ";
List<ODocument> vertices = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OSQLSynchQuery<ODocument>(query)).execute();
Assert.assertEquals(vertices.size(), 1);
db.rollback();
query = "select from C1 where p1 lucene \"abc\" ";
vertices = ODatabaseRecordThreadLocal.INSTANCE.get().command(new OSQLSynchQuery<ODocument>(query)).execute();
Assert.assertEquals(vertices.size(), 0);
}
Aggregations