Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong NUMERIC type parsing #77

Closed
sbooker opened this issue Jan 23, 2020 · 2 comments · Fixed by #78
Closed

Wrong NUMERIC type parsing #77

sbooker opened this issue Jan 23, 2020 · 2 comments · Fixed by #78
Labels
bug Something isn't working

Comments

@sbooker
Copy link

sbooker commented Jan 23, 2020

  • 10000 parsed as 1
  • 0.00001 parsed as 0.1000

DB: PostgreSQL 11

Tests:

    func testNumericParsing() throws {
        let conn = try PostgresConnection.test(on: eventLoop).wait()
        defer { try! conn.close().wait() }
        let rows = try conn.query("""
        select
            '1234.5678'::numeric as a,
            '-123.456'::numeric as b,
            '123456.789123'::numeric as c,
            '3.14159265358979'::numeric as d,
            '10000'::numeric as e,
            '0.00001'::numeric as f
        """).wait()
        XCTAssertEqual(rows[0].column("a")?.string, "1234.5678")
        XCTAssertEqual(rows[0].column("b")?.string, "-123.456")
        XCTAssertEqual(rows[0].column("c")?.string, "123456.789123")
        XCTAssertEqual(rows[0].column("d")?.string, "3.14159265358979")
        XCTAssertEqual(rows[0].column("e")?.string, "10000")
        XCTAssertEqual(rows[0].column("f")?.string, "0.00001")
    }
swift test --filter testNumericParsing
...
PostgresNIOTests.testNumericParsing : XCTAssertEqual failed: ("Optional("1")") is not equal to ("Optional("10000")") -
PostgresNIOTests.testNumericParsing : XCTAssertEqual failed: ("Optional("0.1000")") is not equal to ("Optional("0.00001")") -
@tanner0101 tanner0101 added the bug Something isn't working label Jan 23, 2020
@tanner0101
Copy link
Member

Thanks for reporting @sbooker!

@sbooker
Copy link
Author

sbooker commented Jan 24, 2020

@tanner0101 Thank you for fix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants