ccgus / fmdb

A Cocoa / Objective-C wrapper around SQLite
Other
13.85k stars 2.77k forks source link

FMDB, Swift 3, executeUpdate - compiler build failed #541

Open giluna opened 8 years ago

giluna commented 8 years ago

I'm using FMDB with Swift 3. Everything worked fine on Swift 2 but after making the Swift upgrade I'm getting: "Command failed due to signal: Killed: 9"

After investigating the cause of it I've found that doing "executeUpdate" with about 24 arguments in the ArgumentsArray cause the compiler to be very slow and finally return compilation error.

When decreasing the number of arguments in the array to 20, the compiler build is still slow but succeed to finish successfully.

Any idea why/help will be welcome... !

Here is my code: (Build succeed but uncommenting the 4 lines below will make the compilation build failed. Any other 4 lines will have same result of course)

func insertLocalization(_ localization: Localization) -> Bool {
        print ("Insert Localization: \(localization.localization_object_id!)#\(localization.spot_object_id!)#\(localization.language_code!)")
        sharedInstance.database!.open()
        let isInserted = sharedInstance.database!.executeUpdate(
            "INSERT INTO localizations (" +
                "localization_object_id, " +
                "spot_object_id, " +
                "language_code, " +
                "current_location_enabled, " +
                "spot_title, " +
                "spot_desc, " +
                "local_assistant_phone, " +
                "orientation_360_enabled, " +
                "direction_n_title, " +
                "direction_n_desc, " +
                "direction_ne_title, " +
                "direction_ne_desc, " +
                "direction_e_title, " +
                "direction_e_desc," +
                "direction_se_title, " +
                "direction_se_desc, " +
                "direction_s_title, " +
                "direction_s_desc, " +
                "direction_sw_title, " +
                "direction_sw_desc, " +
                "direction_w_title, " +
                "direction_w_desc, " +
                "direction_nw_title, " +
                "direction_nw_desc) " +
            "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
            withArgumentsIn: [
                // localization.localization_object_id!,
                // localization.spot_object_id!,
                // localization.language_code!,
                // localization.current_location_enabled!,
                localization.spot_title!,
                localization.spot_desc!,
                localization.local_assistant_phone!,
                localization.orientation_360_enabled!,
                localization.direction_n_title!,
                localization.direction_n_desc!,
                localization.direction_ne_title!,
                localization.direction_ne_desc!,
                localization.direction_e_title!,
                localization.direction_e_desc!,
                localization.direction_se_title!,
                localization.direction_se_desc!,
                localization.direction_s_title!,
                localization.direction_s_desc!,
                localization.direction_sw_title!,
                localization.direction_sw_desc!,
                localization.direction_w_title!,
                localization.direction_w_desc!,
                localization.direction_nw_title!,
                localization.direction_nw_desc!
            ])
        sharedInstance.database!.close()
        return isInserted
    }

Thanks !

robertmryan commented 8 years ago

As I said in my reply to your Stack Overflow copy of this question:

This code compiles without incident for me in Xcode 8.0 (8A218a). But if this isn't working for you, I'd suggest splitting the line up, for example

let values =  [localization.localization_object_id!, ..., localization.direction_nw_desc!]

let isInserted = sharedInstance.database!.executeUpdate(
    "INSERT INTO localizations (...) " +
    "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
    withArgumentsIn: values)