Skip to content

Commit 61192d2

Browse files
Fix zeros stripped in conversion from numeric
Fixes a bug causing zeros to be stripped from numeric values such as 10234, producing 1234.
1 parent c8b01a3 commit 61192d2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: Sources/PostgreSQL/Data/PostgreSQLData+String.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extension String: PostgreSQLDataConvertible {
4848

4949
/// depending on our offset, append the string to before or after the decimal point
5050
if offset < metadata.weight.bigEndian + 1 {
51-
integer += string
51+
integer += offset == 0 ? string : String(repeating: "0", count: 4 - string.count) + string
5252
} else {
5353
// Leading zeros matter with fractional
5454
fractional += fractional.count == 0 ? String(repeating: "0", count: 4 - string.count) + string : string

0 commit comments

Comments
 (0)