use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testExpressionAsValue.
@Test
public void testExpressionAsValue() 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.founded Date (default sysdate(), mandatory) unsafe")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("company");
OProperty foundedProperty = companyClass.getProperty("founded");
assertTrue(foundedProperty.isMandatory());
assertFalse(foundedProperty.isNotNull());
assertFalse(foundedProperty.isReadonly());
assertEquals(foundedProperty.getDefaultValue(), "sysdate()");
assertEquals(foundedProperty.getMin(), null);
assertEquals(foundedProperty.getMax(), null);
assertEquals(foundedProperty.getCollate().getName(), "default");
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testLinkedTypeDefaultAndMinMaxUnsafeProperty.
@Test
public void testLinkedTypeDefaultAndMinMaxUnsafeProperty() 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.id EMBEDDEDLIST Integer (DEFAULT 5, MIN 1, MAX 10) 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.EMBEDDEDLIST);
assertEquals(idProperty.getLinkedType(), OType.INTEGER);
assertFalse(idProperty.isMandatory());
assertFalse(idProperty.isNotNull());
assertFalse(idProperty.isReadonly());
assertEquals(idProperty.getDefaultValue(), "5");
assertEquals(idProperty.getMin(), "1");
assertEquals(idProperty.getMax(), "10");
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testExtraSpaces.
@Test
public void testExtraSpaces() 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.id INTEGER ( DEFAULT 5 , MANDATORY ) 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());
assertEquals(idProperty.getDefaultValue(), "5");
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testNullAttributeRegex.
@Test
public void testNullAttributeRegex() throws Exception {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLCreatePropertyTest" + System.nanoTime());
db.create();
db.command(new OCommandSQL("CREATE class myClass")).execute();
db.command(new OCommandSQL("CREATE property myClass.regexp String (REGEX null, mandatory) unsafe")).execute();
OClass companyClass = db.getMetadata().getSchema().getClass("myClass");
OProperty regexp = companyClass.getProperty("regexp");
assertTrue(regexp.isMandatory());
assertEquals(regexp.getRegexp(), null);
db.close();
}
use of com.orientechnologies.orient.core.metadata.schema.OProperty in project orientdb by orientechnologies.
the class OCommandExecutorSQLCreatePropertyTest method testCreateUnsafePropertyWithEmbeddedType.
@Test
public void testCreateUnsafePropertyWithEmbeddedType() 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 UNSAFE")).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);
db.close();
}
Aggregations