Repository: realm/realm-swift
File: src/tightdb/objc/support.mm (Objective-C++)

Code before:
        ++col_ndx;
    }
    return YES;
}

BOOL insert_row(size_t row_ndx, tightdb::Table& table, NSArray * data)
{
    /* 
       Assumption:
       - data has been validated by verify_row
    */

    NSEnumerator *enumerator = [data objectEnumerator];
    id obj;

    /* FIXME: handling of tightdb exceptions => return NO */
    size_t col_ndx = 0;
    while (obj = [enumerator nextObject]) {
        DataType type = table.get_column_type(col_ndx);
        switch (type) {
        case type_Bool:
            table.insert_bool(col_ndx, row_ndx, bool([obj boolValue]));
            break;
        case type_DateTime:
            table.insert_datetime(col_ndx, row_ndx, time_t([obj longValue]));
            break;
        case type_Int:
            table.insert_int(col_ndx, row_ndx, int64_t([obj longValue]));
            break;
        case type_Float:
            table.insert_float(col_ndx, row_ndx, float([obj floatValue]));
            break;
        case type_Double:
            table.insert_double(col_ndx, row_ndx, double([obj doubleValue]));
            break;
        case type_String: 
            {
                StringData sd([obj UTF8String]);
                table.insert_string(col_ndx, row_ndx, sd);
            }
            break;
        case type_Binary:
            {
                BinaryData bd([obj getData], [obj getSize]);
                table.insert_binary(col_ndx, row_ndx, bd);
            }
            break;
        case type_Table:
            if ([obj count]) {
                table.clear_subtable(col_ndx, row_ndx);
            }

Review comment (bug):
To quote a conversation we had earlier with @kspangsege and @kneth : 

The general paradigm I use is

```
switch(column_type)
{
case type_Int:
    ...
    goto ok;
case type_Float:
    ...
    goto ok;
case type_Double:
    ...
    goto ok;
case type_Bool:
case type_DateTime:
case type_String:
case type_Binary:
case type_Mixed:
case type_Table:
    RAISE_COLUMN_TYPE(column_ndx,
        "either int, float, or double");
    return Qnil;
}

RAISE_UNKNOWN_TIGHTDB_TYPE(); // returns from the function

ok:
    return result;
```

The effect is that the compiler will warn of any missing cases, and if
any new cases are added (to core) after the extension has been
compiled, the extension will duly fail.


Code after:
            else {
                return NO;
            }
            break;
           
        }
        ++col_ndx;
    }
    return YES;
}

BOOL insert_row(size_t row_ndx, tightdb::Table& table, NSArray * data)
{
    /* 
       Assumption:
       - data has been validated by verify_row
    */

    NSEnumerator *enumerator = [data objectEnumerator];
    id obj;

    /* FIXME: handling of tightdb exceptions => return NO */
    size_t col_ndx = 0;
    while (obj = [enumerator nextObject]) {
        DataType type = table.get_column_type(col_ndx);
        switch (type) {
        case type_Bool:
            table.insert_bool(col_ndx, row_ndx, bool([obj boolValue]));
            break;
        case type_DateTime:
            if ([obj isKindOfClass:[NSDate class]]) {
                table.insert_datetime(col_ndx, row_ndx, time_t([obj timeIntervalSince1970]));
            }
            else {
                table.insert_datetime(col_ndx, row_ndx, time_t([obj longValue]));
            }
            break;
        case type_Int:
            table.insert_int(col_ndx, row_ndx, int64_t([obj longValue]));
            break;
        case type_Float:
            table.insert_float(col_ndx, row_ndx, float([obj floatValue]));
            break;
        case type_Double:
            table.insert_double(col_ndx, row_ndx, double([obj doubleValue]));
            break;
        case type_String: 
            {
                StringData sd([obj UTF8String]);
                table.insert_string(col_ndx, row_ndx, sd);
            }