diff --git a/.swift-version b/.swift-version index 2469c8d..fbe576f 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-06-20-a +DEVELOPMENT-SNAPSHOT-2016-07-25-a diff --git a/.travis.yml b/.travis.yml index 6e49602..6856422 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,7 @@ os: language: generic sudo: required dist: trusty -osx_image: xcode7.3 -install: - - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/02090c7ede5a637b76e6df1710e83cd0bbe7dcdf/swiftenv-install.sh)" +osx_image: xcode8 script: - # Build SQLite - - swift build - - swift build --configuration release - # Test SQLite - - swift test - + - eval "$(curl -sL swift.qutheory.io/ci)" + - eval "$(curl -sL swift.qutheory.io/codecov)" diff --git a/Sources/SQLite/SQLite.swift b/Sources/SQLite/SQLite.swift index decfcc3..7612a53 100644 --- a/Sources/SQLite/SQLite.swift +++ b/Sources/SQLite/SQLite.swift @@ -36,7 +36,7 @@ public class SQLite { public init(path: String) throws { let options = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX if sqlite3_open_v2(path, &database, options, nil) != SQLITE_OK { - throw Error.connection(database?.errorMessage ?? "") + throw SQLiteError.connection(database?.errorMessage ?? "") } } @@ -64,20 +64,20 @@ public class SQLite { */ public func execute(_ queryString: String, prepareClosure: PrepareClosure = { _ in }) throws -> [Result.Row] { guard let database = self.database else { - throw Error.execute("No database") + throw SQLiteError.execute("No database") } - let statementContainer = UnsafeMutablePointer.init(allocatingCapacity: 1) + let statementContainer = UnsafeMutablePointer.allocate(capacity: 1) defer { - statementContainer.deallocateCapacity(1) + statementContainer.deallocate(capacity: 1) } if sqlite3_prepare_v2(database, queryString, -1, statementContainer, nil) != SQLITE_OK { - throw Error.prepare(database.errorMessage) + throw SQLiteError.prepare(database.errorMessage) } guard let statementPointer = statementContainer.pointee else { - throw Error.execute("Statement pointer errror") + throw SQLiteError.execute("Statement pointer errror") } let statement = Statement(pointer: statementPointer, database: database) @@ -95,7 +95,7 @@ public class SQLite { var value: String? = nil if let text = text { - value = String(cString: UnsafePointer(text)) + value = String(cString: text) } let column: String @@ -112,7 +112,7 @@ public class SQLite { } if sqlite3_finalize(statement.pointer) != SQLITE_OK { - throw Error.execute(database.errorMessage) + throw SQLiteError.execute(database.errorMessage) } return result.rows @@ -132,7 +132,7 @@ public class SQLite { } //MARK: Error - public enum Error: ErrorProtocol { + public enum SQLiteError: Error { case connection(String) case close(String) case prepare(String) @@ -170,7 +170,7 @@ extension SQLite.Database { */ var errorMessage: String { if let raw = sqlite3_errmsg(self) { - return String(cString: raw) ?? "Unknown" + return String(cString: raw) } else { return "Unknown" } @@ -210,20 +210,20 @@ extension SQLite { public func bind(_ value: Double) throws { if sqlite3_bind_double(pointer, nextBindPosition, value) != SQLITE_OK { - throw Error.bind(database.errorMessage) + throw SQLiteError.bind(database.errorMessage) } } public func bind(_ value: Int) throws { if sqlite3_bind_int(pointer, nextBindPosition, Int32(value)) != SQLITE_OK { - throw Error.bind(database.errorMessage) + throw SQLiteError.bind(database.errorMessage) } } public func bind(_ value: String) throws { let strlen = Int32(value.characters.count) if sqlite3_bind_text(pointer, nextBindPosition, value, strlen, SQLITE_TRANSIENT) != SQLITE_OK { - throw Error.bind(database.errorMessage) + throw SQLiteError.bind(database.errorMessage) } }