Search in sources :

Example 66 with OProperty

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();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 67 with OProperty

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();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 68 with OProperty

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();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 69 with OProperty

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();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Example 70 with OProperty

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();
}
Also used : OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) Test(org.testng.annotations.Test)

Aggregations

OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)87 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)69 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)32 Test (org.testng.annotations.Test)30 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)25 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)23 OType (com.orientechnologies.orient.core.metadata.schema.OType)14 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)11 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)9 OIndex (com.orientechnologies.orient.core.index.OIndex)7 ODatabaseObject (com.orientechnologies.orient.core.db.object.ODatabaseObject)6 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)6 Map (java.util.Map)6 Set (java.util.Set)6 OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)5 Collection (java.util.Collection)5 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)4 Field (java.lang.reflect.Field)4 Test (org.junit.Test)4 OException (com.orientechnologies.common.exception.OException)3