diff --git a/.swift-version b/.swift-version index 8590c95..bba74a1 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-05-03-a +DEVELOPMENT-SNAPSHOT-2016-06-06-a diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ae58da5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +os: + - linux + - osx +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)" +script: + # Build Fluent + - swift build + - swift build --configuration release + # Test Fluent + - swift test + diff --git a/Package.swift b/Package.swift index c2d1dde..d99f537 100644 --- a/Package.swift +++ b/Package.swift @@ -4,6 +4,6 @@ let package = Package( name: "FluentSQLite", dependencies: [ .Package(url: "https://github.com/qutheory/csqlite.git", majorVersion: 0, minor: 1), - .Package(url: "https://github.com/qutheory/fluent.git", majorVersion: 0, minor: 3) + .Package(url: "https://github.com/qutheory/fluent.git", majorVersion: 0, minor: 5) ] ) \ No newline at end of file diff --git a/Sources/SQLite.swift b/Sources/SQLite.swift index 18f1b04..a2e004a 100644 --- a/Sources/SQLite.swift +++ b/Sources/SQLite.swift @@ -67,7 +67,13 @@ public class SQLite { if let text = text { value = String(cString: UnsafePointer(text)) } - let column = String(cString: name) + + let column: String + if let name = name { + column = String(cString: name) + } else { + column = "" + } row.data[column] = value } @@ -98,9 +104,11 @@ public class SQLite { } var errorMessage: String { - let raw = sqlite3_errmsg(database) - - return String(cString: raw) ?? "" + if let raw = sqlite3_errmsg(database) { + return String(cString: raw) ?? "Unknown" + } else { + return "Unknown" + } } //MARK: Bind diff --git a/Sources/SQLiteDriver.swift b/Sources/SQLiteDriver.swift index 51bff7f..a71963e 100644 --- a/Sources/SQLiteDriver.swift +++ b/Sources/SQLiteDriver.swift @@ -28,7 +28,7 @@ public class SQLiteDriver: Fluent.Driver { public func execute(_ query: Query) throws -> [[String: Value]] { let sql = SQL(query: query) - print("SQLite executing: \(sql.statement)") + // print("SQLite executing: \(sql.statement)") // useful for developing let results = try database.execute(sql.statement) { preparer in try self.bind(preparer: preparer, to: sql.values) } @@ -57,7 +57,7 @@ public class SQLiteDriver: Fluent.Driver { func bind(preparer: SQLite, to values: [Value]) throws { for value in values { switch value.structuredData { - case .integer(let int): + case .int(let int): try preparer.bind(int) case .double(let double): try preparer.bind(double) @@ -70,6 +70,8 @@ public class SQLiteDriver: Fluent.Driver { case .null: break case .bool(let bool): try preparer.bind(bool) + case .data(let data): + try preparer.bind(String(data)) } } } diff --git a/Tests/FluentSQLite/SQLite3Tests.swift b/Tests/FluentSQLite/SQLite3Tests.swift new file mode 100644 index 0000000..7bf26ba --- /dev/null +++ b/Tests/FluentSQLite/SQLite3Tests.swift @@ -0,0 +1,14 @@ +import XCTest +@testable import FluentSQLite + +class SQLite3Tests: XCTestCase { + static var allTests: [(String, (SQLite3Tests) -> () throws -> Void)] { + return [ + ("testReality", testReality) + ] + } + + func testReality() { + XCTAssert(2 + 2 == 4, "Something is seriously wrong.") + } +} \ No newline at end of file diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..2c577ec --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,10 @@ +#if os(Linux) + +import XCTest +@testable import FluentSQLiteTestSuite + +XCTMain([ + testCase(SQLite3Tests.allTests), +]) + +#endif \ No newline at end of file