use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testNonStrict.
@Test
public void testNonStrict() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.getStorage().getConfiguration().setProperty(OStatement.CUSTOM_STRICT_SQL, "false");
db.command(new OCommandSQL("CREATE CLASS company")).execute();
db.command(new OCommandSQL("CREATE PROPERTY company.id INTEGER (MANDATORY, NOTNULL false, READONLY true, MAX 10, MIN 4, DEFAULT 6) UNSAFE")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty idProperty = companyClass.getProperty(PROP_ID);
assertEquals(idProperty.getName(), PROP_ID);
assertEquals(idProperty.getFullName(), PROP_FULL_ID);
assertEquals(idProperty.getType(), OType.INTEGER);
assertEquals(idProperty.getLinkedType(), null);
assertTrue(idProperty.isMandatory());
assertFalse(idProperty.isNotNull());
assertTrue(idProperty.isReadonly());
assertEquals(idProperty.getMin(), "4");
assertEquals(idProperty.getMax(), "10");
assertEquals(idProperty.getDefaultValue(), "6");
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testBasicUnsafeCreateProperty.
@Test
public void testBasicUnsafeCreateProperty() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.name STRING UNSAFE")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_NAME);
assertEquals(property.getName(), PROP_NAME);
assertEquals(property.getFullName(), PROP_FULL_NAME);
assertEquals(property.getType(), OType.STRING);
assertFalse(property.isMandatory());
assertFalse(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreateNotNullProperty.
@Test
public void testCreateNotNullProperty() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.name STRING (NOTNULL)")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_NAME);
assertEquals(property.getName(), PROP_NAME);
assertEquals(property.getFullName(), PROP_FULL_NAME);
assertFalse(property.isMandatory());
assertTrue(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreatePropertyWithEmbeddedType.
@Test
public void testCreatePropertyWithEmbeddedType() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE Class company")).execute();
db.command(new OCommandSQL("CREATE Property company.officers EMBEDDEDLIST STRING")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_OFFICERS);
assertEquals(property.getName(), PROP_OFFICERS);
assertEquals(property.getFullName(), PROP_FULL_OFFICERS);
assertEquals(property.getType(), OType.EMBEDDEDLIST);
assertEquals(property.getLinkedType(), OType.STRING);
assertFalse(property.isMandatory());
assertFalse(property.isNotNull());
assertFalse(property.isReadonly());
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreateReadOnlyProperty.
@Test
public void testCreateReadOnlyProperty() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class company")).execute();
db.command(new OCommandSQL("CREATE property company.name STRING (READONLY)")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty property = companyClass.getProperty(PROP_NAME);
assertEquals(property.getName(), PROP_NAME);
assertEquals(property.getFullName(), PROP_FULL_NAME);
assertFalse(property.isMandatory());
assertFalse(property.isNotNull());
assertTrue(property.isReadonly());
db.close();
}
Aggregations