Repository: realm/realm-swift
File: Realm/RLMQueryUtil.mm (Objective-C++)

Code before:
            break;
        case type_DateTime:
            add_datetime_constraint_to_query(query, operatorType, index, [value timeIntervalSince1970]);
            break;
        case type_Double:
            add_numeric_constraint_to_query(query, type, operatorType, index, [value doubleValue]);
            break;
        case type_Float:
            add_numeric_constraint_to_query(query, type, operatorType, index, [value floatValue]);
            break;
        case type_Int:
            add_numeric_constraint_to_query(query, type, operatorType, index, [value longLongValue]);
            break;
        case type_String:
            add_string_constraint_to_query(query, operatorType, options, index, value);
            break;
        case type_Binary:
            add_binary_constraint_to_query(query, operatorType, index, value);
            break;
        case type_Link:
            add_link_constraint_to_query(query, operatorType, index, value);
            break;
        default:
            @throw RLMPredicateException(@"Unsupported predicate value type",
                                         @"Object type %@ not supported", RLMTypeToString(type));
    }
}

void update_query_with_value_expression(RLMSchema *schema,
                                        RLMObjectSchema *desc,
                                        tightdb::Query &query,
                                        NSString *keyPath,
                                        id value,
                                        NSComparisonPredicate *pred)
{
    // split keypath
    NSArray *paths = [keyPath componentsSeparatedByString:@"."];
    RLMProperty *prop = desc[paths[0]];

    // make sure we are not comparing on RLMArray
    if (prop.type == RLMPropertyTypeArray) {
        @throw RLMPredicateException(@"Invalid predicate",
                                     @"RLMArray predicates must contain the ANY modifier");
    }

    // check to see if this is a link query
    if (paths.count > 1) {
        update_link_query_with_value_expression(schema, desc, query, paths, value, pred);
        return;
    }
    

Review comment (suggestion):
This is not new to this PR, but still: We should avoid "default" in switch statements when we switch on an enum. Instead list the types that should give this exception. This way the compiler will provide a warning when a new type is added that isn't handled by any "case".


Code after:
    switch (type) {
        case type_Bool:
            add_bool_constraint_to_query(query, operatorType, index, bool([value boolValue]));
            break;
        case type_DateTime:
            add_datetime_constraint_to_query(query, operatorType, index, [value timeIntervalSince1970]);
            break;
        case type_Double:
            add_numeric_constraint_to_query(query, type, operatorType, index, [value doubleValue]);
            break;
        case type_Float:
            add_numeric_constraint_to_query(query, type, operatorType, index, [value floatValue]);
            break;
        case type_Int:
            add_numeric_constraint_to_query(query, type, operatorType, index, [value longLongValue]);
            break;
        case type_String:
            add_string_constraint_to_query(query, operatorType, options, index, value);
            break;
        case type_Binary:
            add_binary_constraint_to_query(query, operatorType, index, value);
            break;
        case type_Link:
            add_link_constraint_to_query(query, operatorType, index, value);
            break;
        default:
            @throw RLMPredicateException(@"Unsupported predicate value type",
                                         @"Object type %@ not supported", RLMTypeToString(type));
    }
}

void update_query_with_value_expression(RLMSchema *schema,
                                        RLMObjectSchema *desc,
                                        tightdb::Query &query,
                                        NSString *keyPath,
                                        id value,
                                        NSComparisonPredicate *pred)
{
    // split keypath
    NSArray *paths = [keyPath componentsSeparatedByString:@"."];
    RLMProperty *prop = desc[paths[0]];

    // make sure we are not comparing on RLMArray
    if (prop.type == RLMPropertyTypeArray) {
        @throw RLMPredicateException(@"Invalid predicate",
                                     @"RLMArray predicates must contain the ANY modifier");
    }

    // check to see if this is a link query
    if (paths.count > 1) {
        update_link_query_with_value_expression(schema, desc, query, paths, value, pred);