Skip to content

Commit

Permalink
Merge pull request #7 from qutheory/snapshot-06-06
Browse files Browse the repository at this point in the history
update to snapshot 06-06
  • Loading branch information
tanner0101 committed Jun 8, 2016
2 parents 67d9bb2 + 6d0edbb commit 4a3a4b7
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-05-03-a
DEVELOPMENT-SNAPSHOT-2016-06-06-a
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
)
16 changes: 12 additions & 4 deletions Sources/SQLite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Sources/SQLiteDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SQLiteDriver: Fluent.Driver {
public func execute<T: Model>(_ query: Query<T>) 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)
}
Expand Down Expand Up @@ -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)
Expand All @@ -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))
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions Tests/FluentSQLite/SQLite3Tests.swift
Original file line number Diff line number Diff line change
@@ -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.")
}
}
10 changes: 10 additions & 0 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#if os(Linux)

import XCTest
@testable import FluentSQLiteTestSuite

XCTMain([
testCase(SQLite3Tests.allTests),
])

#endif

0 comments on commit 4a3a4b7

Please sign in to comment.