diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8364e8ae..c482683e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,8 +57,11 @@ jobs: postgres-auth: md5 - postgres-image: postgres:12 postgres-auth: trust + swift-version: + - swift:6.0 + - swift:5.10-noble container: - image: swift:5.10-noble + image: ${{ matrix.swift-version }} volumes: [ 'pgrunshare:/var/run/postgresql' ] runs-on: ubuntu-latest env: diff --git a/Tests/IntegrationTests/PostgresNIOTests.swift b/Tests/IntegrationTests/PostgresNIOTests.swift index ff59209b..9442e4dc 100644 --- a/Tests/IntegrationTests/PostgresNIOTests.swift +++ b/Tests/IntegrationTests/PostgresNIOTests.swift @@ -664,6 +664,32 @@ final class PostgresNIOTests: XCTestCase { XCTAssertEqual(row?[data: "balance"].decimal, Decimal(string: "123456.789123")!) } + func testDateSerialization() { + let date = Date() + var conn: PostgresConnection? + XCTAssertNoThrow(conn = try PostgresConnection.test(on: eventLoop).wait()) + defer { XCTAssertNoThrow( try conn?.close().wait() ) } + + XCTAssertNoThrow(_ = try conn?.simpleQuery("DROP TABLE IF EXISTS \"table1\"").wait()) + XCTAssertNoThrow(_ = try conn?.simpleQuery(""" + CREATE TABLE table1 ( + "date" TIMESTAMP WITH TIME ZONE NOT NULL + ); + """).wait()) + defer { XCTAssertNoThrow(_ = try conn?.simpleQuery("DROP TABLE \"table1\"").wait()) } + + XCTAssertNoThrow(_ = try conn?.query("INSERT INTO table1 VALUES ($1)", [.init(date: date)]).wait()) + + var rows: PostgresQueryResult? + XCTAssertNoThrow(rows = try conn?.query(""" + SELECT + "date" + FROM table1 + """).wait()) + let row = rows?.first?.makeRandomAccess() + XCTAssertEqual(row?[data: "date"].date?.timeIntervalSince1970, date.timeIntervalSince1970) + } + func testMoney() { var conn: PostgresConnection? XCTAssertNoThrow(conn = try PostgresConnection.test(on: eventLoop).wait())