Skip to content

Commit dee0d87

Browse files
committed
add support for decoding integers from NUMERIC data
1 parent 3fcc626 commit dee0d87

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/PostgreSQL/Data/PostgreSQLData+FixedWidthInteger.swift

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ extension FixedWidthInteger {
2525
throw PostgreSQLError.decode(self, from: data)
2626
}
2727
i = value.as(Int64.self, default: 0).bigEndian.cast(to: Self.self)
28+
case .numeric:
29+
guard let int = try Self(String.convertFromPostgreSQLData(data)) else {
30+
throw PostgreSQLError.decode(Int.self, from: data)
31+
}
32+
i = int
2833
default: throw PostgreSQLError.decode(self, from: data)
2934
}
3035
guard let value = i else {

Tests/PostgreSQLTests/PostgreSQLConnectionTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class PostgreSQLConnectionTests: XCTestCase {
236236

237237
func testURLParsing() throws {
238238
let databaseURL = "postgres://username:password@localhost:5432/database"
239-
let config = try PostgreSQLDatabaseConfig(url: databaseURL)!
239+
let config = PostgreSQLDatabaseConfig(url: databaseURL)!
240240
XCTAssertEqual("\(config.serverAddress)", "ServerAddress(storage: PostgreSQL.PostgreSQLConnection.ServerAddress.Storage.tcp(hostname: \"localhost\", port: 5432))")
241241
XCTAssertEqual(config.username, "username")
242242
XCTAssertEqual(config.password, "password")

0 commit comments

Comments
 (0)