use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class LuceneInsertUpdateSingleDocumentNoTxTest method init.
@Before
public void init() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class LuceneInsertUpdateTest method init.
@Before
public void init() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class LuceneInsertUpdateTransactionTest method init.
@Before
public void init() {
OSchema schema = db.getMetadata().getSchema();
OClass oClass = schema.createClass("City");
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class CRUDDocumentValidationTest method validationDisabledAdDatabaseLevel.
@Test(dependsOnMethods = "validationMandatoryNullableNoCloseDb")
public void validationDisabledAdDatabaseLevel() throws ParseException {
database.getMetadata().reload();
try {
ODocument doc = new ODocument("MyTestClass");
doc.save();
Assert.fail();
} catch (OValidationException e) {
}
database.command(new OCommandSQL("ALTER DATABASE " + ODatabase.ATTRIBUTES.VALIDATION.name() + " FALSE")).execute();
database.setValidationEnabled(false);
try {
ODocument doc = new ODocument("MyTestClass");
doc.save();
doc.delete();
} finally {
database.setValidationEnabled(true);
database.command(new OCommandSQL("ALTER DATABASE " + ODatabase.ATTRIBUTES.VALIDATION.name() + " TRUE")).execute();
}
}
use of com.orientechnologies.orient.core.sql.OCommandSQL in project orientdb by orientechnologies.
the class CRUDDocumentValidationTest method createSchemaForMandatoryNullableTest.
@Test(dependsOnMethods = "closeDb")
public void createSchemaForMandatoryNullableTest() throws ParseException {
if (database.getMetadata().getSchema().existsClass("MyTestClass")) {
database.getMetadata().getSchema().dropClass("MyTestClass");
database.getMetadata().getSchema().reload();
}
database.command(new OCommandSQL("CREATE CLASS MyTestClass")).execute();
database.command(new OCommandSQL("CREATE PROPERTY MyTestClass.keyField STRING")).execute();
database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.keyField MANDATORY true")).execute();
database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.keyField NOTNULL true")).execute();
database.command(new OCommandSQL("CREATE PROPERTY MyTestClass.dateTimeField DATETIME")).execute();
database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.dateTimeField MANDATORY true")).execute();
database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.dateTimeField NOTNULL false")).execute();
database.command(new OCommandSQL("CREATE PROPERTY MyTestClass.stringField STRING")).execute();
database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.stringField MANDATORY true")).execute();
database.command(new OCommandSQL("ALTER PROPERTY MyTestClass.stringField NOTNULL false")).execute();
database.command(new OCommandSQL("INSERT INTO MyTestClass (keyField,dateTimeField,stringField) VALUES (\"K1\",null,null)")).execute();
database.reload();
database.getMetadata().reload();
database.close();
database.open("admin", "admin");
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM MyTestClass WHERE keyField = ?");
List<ODocument> result = database.query(query, "K1");
Assert.assertEquals(1, result.size());
ODocument doc = result.get(0);
Assert.assertTrue(doc.containsField("keyField"));
Assert.assertTrue(doc.containsField("dateTimeField"));
Assert.assertTrue(doc.containsField("stringField"));
}
Aggregations