stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.7k stars 1.56k forks source link

Result Enum refactor #1106

Closed NightDrivers closed 2 years ago

NightDrivers commented 2 years ago

public enum Result: Error {

fileprivate static let successCodes: Set = [SQLITE_OK, SQLITE_ROW, SQLITE_DONE]
case error(message: String, code: Int32, statement: Statement?)

init?(errorCode: Int32, connection: Connection, statement: Statement? = nil) {
    guard !Result.successCodes.contains(errorCode) else { return nil }

    let message = String(cString: sqlite3_errmsg(connection.handle))
    self = .error(message: message, code: errorCode, statement: statement)
}

}

It conflicts with swift.Result

jberkel commented 2 years ago

What are you suggesting? Binding conflicts as well. It's not that these are reserved names.

NightDrivers commented 2 years ago

I know these are not reserved names. Because this enumeration has the same name as the Result of Swift standard library. When i import this library, all the Result in my project need to use as Swift.Result. which makes me a little uncomfortable, i think there is some solutions to relieve it.

jberkel commented 2 years ago

you could try to import only the classes you need:

import class SQLite.Connection
NightDrivers commented 2 years ago

Ok! Thanks!