Skip to content

Commit

Permalink
Merge pull request #20 from vapor/fix-int-64-fetch
Browse files Browse the repository at this point in the history
fix int 64 fetch
  • Loading branch information
tanner0101 authored Jul 19, 2017
2 parents e0118be + dbfe33d commit 92d9195
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sources/SQLite/SQLite+Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension SQLite {
data[column] = .string(value)

case SQLITE_INTEGER:
let integer = Int(sqlite3_column_int(pointer, i))
let integer = Int(sqlite3_column_int64(pointer, i))
data[column] = .number(.int(integer))

case SQLITE_FLOAT: // as in floating point, actually returns a double.
Expand Down
26 changes: 15 additions & 11 deletions Tests/SQLiteTests/SQLite3Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import XCTest
import Node

class SQLite3Tests: XCTestCase {
static let allTests = [("testTables", testTables),
("testUnicode", testUnicode)]

var database:SQLite!

override func setUp() {
Expand Down Expand Up @@ -77,17 +74,24 @@ class SQLite3Tests: XCTestCase {
}

func testBigInts() throws {
let bar: UInt64 = 1 << 20
let baz: UInt64 = 1 << 40
let max = Int.max

_ = try database.execute("DROP TABLE IF EXISTS foo")
_ = try database.execute("CREATE TABLE foo (bar BIGINT, baz BIGINT)")
_ = try database.execute("INSERT INTO foo VALUES (\(bar), (\(baz)))")
_ = try! database.execute("DROP TABLE IF EXISTS foo")
_ = try! database.execute("CREATE TABLE foo (max INT)")
_ = try! database.execute("INSERT INTO foo VALUES (?)") { statement in
try! statement.bind(max)

}

if let result = try database.execute("SELECT * FROM foo").first {
XCTAssertEqual(result.data["bar"], bar.makeNode(in: nil))
XCTAssertEqual(result.data["baz"], baz.makeNode(in: nil))
if let result = try! database.execute("SELECT * FROM foo").first {
XCTAssertEqual(result.data["max"], max.makeNode(in: nil))
}
}


static let allTests = [
("testTables", testTables),
("testUnicode", testUnicode),
("testBigInts", testBigInts),
]
}

0 comments on commit 92d9195

Please sign in to comment.