postgres-nio icon indicating copy to clipboard operation
postgres-nio copied to clipboard

Empty Query Triggers Precondition Failure

Open MahdiBM opened this issue 1 year ago • 0 comments

Describe the issue

An empty query with no query content (e.g. only comments) triggers a precondition failure.

Vapor version

1.21.5

Operating system and version

macOS 15

Swift version

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10) Target: arm64-apple-macosx15.0

Steps to reproduce

Add/Run this in PSQLIntegrationTests.swift:

    func testCommentOnlyQueryTriggersPrecondition() {
        let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
        defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
        let eventLoop = eventLoopGroup.next()

        var conn: PostgresConnection?
        XCTAssertNoThrow(conn = try PostgresConnection.test(on: eventLoop).wait())
        defer { XCTAssertNoThrow(try conn?.close().wait()) }

        _ = try conn?.query("-- Some comments", logger: .psqlTest).wait()
    }

Outcome

Screenshot 2024-06-19 at 2 52 39 PM

Additional notes

No response

MahdiBM avatar Jun 19 '24 11:06 MahdiBM