Example #1
0
PropertyType ObjectSchema::from_core_type(Descriptor const& table, size_t col)
{
    auto optional = table.is_nullable(col) ? PropertyType::Nullable : PropertyType::Required;
    switch (table.get_column_type(col)) {
        case type_Int:       return PropertyType::Int | optional;
        case type_Float:     return PropertyType::Float | optional;
        case type_Double:    return PropertyType::Double | optional;
        case type_Bool:      return PropertyType::Bool | optional;
        case type_String:    return PropertyType::String | optional;
        case type_Binary:    return PropertyType::Data | optional;
        case type_Timestamp: return PropertyType::Date | optional;
        case type_Mixed:     return PropertyType::Any | optional;
        case type_Link:      return PropertyType::Object | PropertyType::Nullable;
        case type_LinkList:  return PropertyType::Object | PropertyType::Array;
        case type_Table:     return from_core_type(*table.get_subdescriptor(col), 0) | PropertyType::Array;
        default: REALM_UNREACHABLE();
    }
}