Skip to content

Commit

Permalink
support parameter status messages in query / simpleQuery (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Jul 16, 2020
1 parent 711b726 commit ffa8b35
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
@@ -1,7 +1,7 @@
import NIO

extension PostgresMessage {
public struct ParameterStatus: CustomStringConvertible {
public struct ParameterStatus: PostgresMessageType, CustomStringConvertible {
/// Parses an instance of this message type from a byte buffer.
public static func parse(from buffer: inout ByteBuffer) throws -> ParameterStatus {
guard let parameter = buffer.readNullTerminatedString() else {
Expand Down
2 changes: 2 additions & 0 deletions Sources/PostgresNIO/PostgresDatabase+Query.swift
Expand Up @@ -174,6 +174,8 @@ private final class PostgresParameterizedQuery: PostgresRequest {
return []
case .readyForQuery:
return nil
case .parameterStatus:
return []
default: throw PostgresError.protocol("Unexpected message during query: \(message)")
}
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/PostgresNIO/PostgresDatabase+SimpleQuery.swift
Expand Up @@ -56,6 +56,8 @@ private final class PostgresSimpleQuery: PostgresRequest {
return []
case .notificationResponse:
return []
case .parameterStatus:
return []
default:
throw PostgresError.protocol("Unexpected message during simple query: \(message)")
}
Expand Down
9 changes: 9 additions & 0 deletions Tests/PostgresNIOTests/PostgresNIOTests.swift
Expand Up @@ -928,6 +928,15 @@ final class PostgresNIOTests: XCTestCase {
let res = try conn.query(#"SELECT '{"foo", "bar", "baz"}'::VARCHAR[] as foo"#).wait()
XCTAssertEqual(res[0].column("foo")?.array(of: String.self), ["foo", "bar", "baz"])
}

// https://github.com/vapor/postgres-nio/issues/115
func testSetTimeZone() throws {
let conn = try PostgresConnection.test(on: eventLoop).wait()
defer { try! conn.close().wait() }

_ = try conn.simpleQuery("SET TIME ZONE INTERVAL '+5:45' HOUR TO MINUTE").wait()
_ = try conn.query("SET TIME ZONE INTERVAL '+5:45' HOUR TO MINUTE").wait()
}
}

func env(_ name: String) -> String? {
Expand Down

0 comments on commit ffa8b35

Please sign in to comment.