diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80d1a1878..2cbe2cef7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: - name: Install curl for Codecov run: apt-get update -y -q && apt-get install -y curl - name: Check out package - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Run unit tests with Thread Sanitizer run: | swift test --filter='^(PostgresNIOTests|ConnectionPoolModuleTests)' --sanitize=thread --enable-code-coverage @@ -92,15 +92,15 @@ jobs: [[ -z "${SWIFT_VERSION}" ]] && SWIFT_VERSION="$(cat /.swift_tag 2>/dev/null || true)" printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version - name: Check out package - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: { path: 'postgres-nio' } - name: Run integration tests run: swift test --package-path postgres-nio --filter=^IntegrationTests - name: Check out postgres-kit dependent - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: { repository: 'vapor/postgres-kit', path: 'postgres-kit' } - name: Check out fluent-postgres-driver dependent - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: { repository: 'vapor/fluent-postgres-driver', path: 'fluent-postgres-driver' } - name: Use local package in dependents run: | @@ -136,7 +136,6 @@ jobs: POSTGRES_PASSWORD: 'test_password' POSTGRES_DB: 'postgres' POSTGRES_AUTH_METHOD: ${{ matrix.postgres-auth }} - POSTGRES_SOCKET: '/tmp/.s.PGSQL.5432' POSTGRES_FORMULA: ${{ matrix.postgres-formula }} steps: - name: Select latest available Xcode @@ -151,7 +150,7 @@ jobs: pg_ctl start --wait timeout-minutes: 15 - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Run all tests run: swift test --enable-code-coverage - name: Submit code coverage @@ -165,7 +164,7 @@ jobs: container: swift:noble steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 # https://github.com/actions/checkout/issues/766 diff --git a/Sources/PostgresNIO/Data/PostgresData+Numeric.swift b/Sources/PostgresNIO/Data/PostgresData+Numeric.swift index e736a61cc..55f0e8fee 100644 --- a/Sources/PostgresNIO/Data/PostgresData+Numeric.swift +++ b/Sources/PostgresNIO/Data/PostgresData+Numeric.swift @@ -4,7 +4,7 @@ import struct Foundation.Decimal public struct PostgresNumeric: CustomStringConvertible, CustomDebugStringConvertible, ExpressibleByStringLiteral { /// The number of digits after this metadata internal var ndigits: Int16 - /// How many of the digits are before the decimal point (always add 1) + /// How many positions before or after the deicmal point the value is offset by internal var weight: Int16 /// If 0x4000, this number is negative. See NUMERIC_NEG in /// https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/numeric.c @@ -159,8 +159,10 @@ public struct PostgresNumeric: CustomStringConvertible, CustomDebugStringConvert let offset: Int16 if self.weight > 0 { offset = (self.weight + 1) - self.ndigits + } else if self.weight < 0 { + offset = abs(self.weight + 1) } else { - offset = abs(self.weight) - self.ndigits + offset = 0 } if offset > 0 { for _ in 0..