use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.
the class SQLDropClassTest method testSimpleDrop.
@Test
public void testSimpleDrop() {
ODatabaseDocument db = new ODatabaseDocumentTx("memory:" + SQLDropClassTest.class.getName());
db.create();
try {
Assert.assertFalse(db.getMetadata().getSchema().existsClass("testSimpleDrop"));
db.command(new OCommandSQL("create class testSimpleDrop")).execute();
Assert.assertTrue(db.getMetadata().getSchema().existsClass("testSimpleDrop"));
db.command(new OCommandSQL("Drop class testSimpleDrop")).execute();
Assert.assertFalse(db.getMetadata().getSchema().existsClass("testSimpleDrop"));
} finally {
db.drop();
}
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.
the class SQLDropClassTest method testIfExists.
@Test
public void testIfExists() {
ODatabaseDocument db = new ODatabaseDocumentTx("memory:" + SQLDropClassTest.class.getName() + "_ifNotExists");
db.create();
try {
Assert.assertFalse(db.getMetadata().getSchema().existsClass("testIfExists"));
db.command(new OCommandSQL("create class testIfExists if not exists")).execute();
db.getMetadata().getSchema().reload();
Assert.assertTrue(db.getMetadata().getSchema().existsClass("testIfExists"));
db.command(new OCommandSQL("drop class testIfExists if exists")).execute();
db.getMetadata().getSchema().reload();
Assert.assertFalse(db.getMetadata().getSchema().existsClass("testIfExists"));
db.command(new OCommandSQL("drop class testIfExists if exists")).execute();
db.getMetadata().getSchema().reload();
Assert.assertFalse(db.getMetadata().getSchema().existsClass("testIfExists"));
} finally {
db.drop();
}
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.
the class TestOrderBy method testGermanOrderBy.
@Test
public void testGermanOrderBy() {
ODatabaseDocument db = new ODatabaseDocumentTx("memory:testGermanOrderBy");
db.set(ATTRIBUTES.LOCALECOUNTRY, Locale.GERMANY.getCountry());
db.set(ATTRIBUTES.LOCALELANGUAGE, Locale.GERMANY.getLanguage());
db.create();
try {
db.getMetadata().getSchema().createClass("test");
ORecord res1 = db.save(new ODocument("test").field("name", "Ähhhh"));
ORecord res2 = db.save(new ODocument("test").field("name", "Ahhhh"));
ORecord res3 = db.save(new ODocument("test").field("name", "Zebra"));
List<?> queryRes = db.query(new OSQLSynchQuery<Object>("select from test order by name"));
assertEquals(queryRes.get(0), res2);
assertEquals(queryRes.get(1), res1);
assertEquals(queryRes.get(2), res3);
queryRes = db.query(new OSQLSynchQuery<Object>("select from test order by name desc "));
assertEquals(queryRes.get(0), res3);
assertEquals(queryRes.get(1), res1);
assertEquals(queryRes.get(2), res2);
} finally {
db.drop();
}
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.
the class ODeleteStatementTest method deleteFromSubqueryWithWhereTest.
public void deleteFromSubqueryWithWhereTest() {
ODatabaseDocument database = new ODatabaseDocumentTx("memory:ODeleteStatementTestFromSubqueryWithWhereTest");
database.create();
try {
database.command(new OCommandSQL("create class Foo")).execute();
database.command(new OCommandSQL("create class Bar")).execute();
final ODocument doc1 = new ODocument("Foo").field("k", "key1");
final ODocument doc2 = new ODocument("Foo").field("k", "key2");
final ODocument doc3 = new ODocument("Foo").field("k", "key3");
doc1.save();
doc2.save();
doc3.save();
List<ODocument> list = new ArrayList<ODocument>();
list.add(doc1);
list.add(doc2);
list.add(doc3);
final ODocument bar = new ODocument("Bar").field("arr", list);
bar.save();
database.command(new OCommandSQL("delete from (select expand(arr) from Bar) where k = 'key2'")).execute();
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from Foo"));
Assert.assertNotNull(result);
Assert.assertEquals(result.size(), 2);
for (ODocument doc : result) {
Assert.assertNotEquals(doc.field("k"), "key2");
}
} finally {
database.close();
}
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocument in project orientdb by orientechnologies.
the class OrientJdbcStatementDMLtest method shoulCreateClassWithProperties.
@Test
public void shoulCreateClassWithProperties() throws IOException, SQLException {
Statement stmt = conn.createStatement();
stmt.executeUpdate("CREATE CLASS Account ");
stmt.executeUpdate("CREATE PROPERTY Account.id INTEGER ");
stmt.executeUpdate("CREATE PROPERTY Account.birthDate DATE ");
stmt.executeUpdate("CREATE PROPERTY Account.binary BINARY ");
stmt.close();
// double value test pattern?
ODatabaseDocument database = conn.getDatabase();
assertThat(database.getClusterIdByName("account")).isNotNull();
OClass account = database.getMetadata().getSchema().getClass("Account");
assertThat(account).isNotNull();
assertThat(account.getProperty("id").getType()).isEqualTo(OType.INTEGER);
assertThat(account.getProperty("birthDate").getType()).isEqualTo(OType.DATE);
assertThat(account.getProperty("binary").getType()).isEqualTo(OType.BINARY);
}
Aggregations