Wayne Fulcher
Wayne Fulcher

Reputation: 861

Docs for the latest version of SQLite.swift

After updating Xcode to 6.3 today I finally was able to totally remove sqlite.swift and reinstall it. And after having fixed about 50 errors caused by something changing I am down to about 15 errors remaining and all of them have something to do with the new sqlite.swift. I have searched for new docs to cover the syntax changes to no avail. Some errors I have found other posts about and was able to fix.

So this function that used to work now complains about the ? after the delete()?... The error message is "Optional chain has no effect, expression already produces Int?'. The recommendation is to remove the ?

func delete(id: Int) {
    let rows = db[schema.tableName]
    rows.filter(schema.id == id).delete()?
}

If I remove the ? after delete() then it tells me "cannot invoke 'delete' with no argument". I searched the source code and the code completion, all of which does not show any arguments.

Also on update statements I now get this error: Example code:

rows.filter(schema.id == id)
    .update(schema.acctID <- acctID, schema.accessCode <- accessCode, schema.status <- 0)

Error: cannot invoke 'update' with an argument list of type '(Setter, Setter, Setter)'

Upvotes: 1

Views: 424

Answers (1)

stephencelis
stephencelis

Reputation: 4964

Swift 1.2 removed the ability to coerce using a trailing ?. You can use ! if the statement shouldn't fail:

func delete(id: Int) {
    let rows = db[schema.tableName]
    rows.filter(schema.id == id).delete()!
}

Or you can chain the delete() call to a tuple member, instead:

rows.filter(schema.id == id).delete().changes

This has been a continual support issue, so the interface may change in the near future.

The update() call needs to be fixed the same way:

rows.filter(schema.id == id)
    .update(
        schema.acctID <- acctID,
        schema.accessCode <- accessCode,
        schema.status <- 0)! // or .changes

Upvotes: 1

Related Questions