Skip to content

Commit

Permalink
add support for decoding integers from NUMERIC data
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Sep 8, 2018
1 parent 3fcc626 commit dee0d87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ extension FixedWidthInteger {
throw PostgreSQLError.decode(self, from: data)
}
i = value.as(Int64.self, default: 0).bigEndian.cast(to: Self.self)
case .numeric:
guard let int = try Self(String.convertFromPostgreSQLData(data)) else {
throw PostgreSQLError.decode(Int.self, from: data)
}
i = int
default: throw PostgreSQLError.decode(self, from: data)
}
guard let value = i else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/PostgreSQLTests/PostgreSQLConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class PostgreSQLConnectionTests: XCTestCase {

func testURLParsing() throws {
let databaseURL = "postgres://username:password@localhost:5432/database"
let config = try PostgreSQLDatabaseConfig(url: databaseURL)!
let config = PostgreSQLDatabaseConfig(url: databaseURL)!
XCTAssertEqual("\(config.serverAddress)", "ServerAddress(storage: PostgreSQL.PostgreSQLConnection.ServerAddress.Storage.tcp(hostname: \"localhost\", port: 5432))")
XCTAssertEqual(config.username, "username")
XCTAssertEqual(config.password, "password")
Expand Down

0 comments on commit dee0d87

Please sign in to comment.