0

I just upgraded to the latest stable version of both XCode (10.3) and SQLite.swift for macOS and I now experience one build issue, maybe obvious, that I cannot seem to be able to fix.

func strings(for symbols: [Character]) -> [String] {
    let timing = Date()
    if let stringdom = stringdom {
        let strings = stringdom.strings(for: symbols)
        os_log("LEXICON...Strings()→Cache: %.2f seconds", log: LexiconLog, type: .debug, Date().timeIntervalSince(timing))
        return strings
    } else if let connection = connection {
        do {
            let isSubsetOf: (Expression<String>, Expression<String>) -> Expression<Bool> = (
                try connection.createFunction("isSubsetOf", deterministic: true) { string, symbols in
                    return string.isSubsetOf(symbols)
                }
            )
            let strings = try connection.prepare(
                SQLiteDatabaseLexicon.tableWords.select(SQLiteDatabaseLexicon.tableWordsColumnString).filter(
                    isSubsetOf(SQLiteDatabaseLexicon.tableWordsColumnString, Expression<String>(String(symbols)))
                )
            ).map { $0[SQLiteDatabaseLexicon.tableWordsColumnString] }
            os_log("LEXICON...Strings()→Database: %.2f seconds", log: LexiconLog, type: .debug, Date().timeIntervalSince(timing))
            return strings
        } catch {
            os_log("FAULT...SQLite database content could not be accessed", log: LexiconLog, type: .fault)
        }
    }
    return []
}

The error I get on the call to createFunction(), next to the block's parameters, is:

Contextual closure type '([Binding?]) -> Binding?' expects 1 argument, but 2 were used in closure body

The exact same code used to compile before I upgraded. Any help in solving this build issue is appreciated, thanks.

jmdecombe
  • 782
  • 6
  • 16
  • Does not seem to be a new issue in 10.3 See this older case: https://stackoverflow.com/questions/32981301/how-to-create-a-type-safe-custom-function-in-sqlite-swift?rq=1 – claude31 Aug 06 '19 at 20:55
  • I also just updated SQLite.swift from a version of about a year ago. Also, this is code running on macOS so I linked to the macOS framework whereas my code was for iOS last year. At any rate, I do not see any insight in this other case, and my code appears to correctly define 2 parameters and use 2 as well in the block. – jmdecombe Aug 06 '19 at 21:19

0 Answers0