Skip to content

Commit

Permalink
fix: Quotes LISTEN queries
Browse files Browse the repository at this point in the history
  • Loading branch information
NeedleInAJayStack committed Mar 18, 2024
1 parent 0b48f79 commit 0908fc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/PostgresNIO/New/PostgresChannelHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ final class PostgresChannelHandler: ChannelDuplexHandler {
private func makeStartListeningQuery(channel: String, context: ChannelHandlerContext) -> PSQLTask {
let promise = context.eventLoop.makePromise(of: PSQLRowStream.self)
let query = ExtendedQueryContext(
query: PostgresQuery(unsafeSQL: "LISTEN \(channel);"),
query: PostgresQuery(unsafeSQL: #"LISTEN "\#(channel)";"#),
logger: self.logger,
promise: promise
)
Expand Down Expand Up @@ -642,7 +642,7 @@ final class PostgresChannelHandler: ChannelDuplexHandler {
private func makeUnlistenQuery(channel: String, context: ChannelHandlerContext) -> PSQLTask {
let promise = context.eventLoop.makePromise(of: PSQLRowStream.self)
let query = ExtendedQueryContext(
query: PostgresQuery(unsafeSQL: "UNLISTEN \(channel);"),
query: PostgresQuery(unsafeSQL: #"UNLISTEN "\#(channel)";"#),
logger: self.logger,
promise: promise
)
Expand Down
10 changes: 5 additions & 5 deletions Tests/PostgresNIOTests/New/PostgresConnectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PostgresConnectionTests: XCTestCase {
}

let listenMessage = try await channel.waitForUnpreparedRequest()
XCTAssertEqual(listenMessage.parse.query, "LISTEN foo;")
XCTAssertEqual(listenMessage.parse.query, #"LISTEN "foo";"#)

try await channel.writeInbound(PostgresBackendMessage.parseComplete)
try await channel.writeInbound(PostgresBackendMessage.parameterDescription(.init(dataTypes: [])))
Expand All @@ -63,7 +63,7 @@ class PostgresConnectionTests: XCTestCase {
try await channel.writeInbound(PostgresBackendMessage.notification(.init(backendPID: 12, channel: "foo", payload: "wooohooo")))

let unlistenMessage = try await channel.waitForUnpreparedRequest()
XCTAssertEqual(unlistenMessage.parse.query, "UNLISTEN foo;")
XCTAssertEqual(unlistenMessage.parse.query, #"UNLISTEN "foo";"#)

try await channel.writeInbound(PostgresBackendMessage.parseComplete)
try await channel.writeInbound(PostgresBackendMessage.parameterDescription(.init(dataTypes: [])))
Expand Down Expand Up @@ -111,7 +111,7 @@ class PostgresConnectionTests: XCTestCase {
}

let listenMessage = try await channel.waitForUnpreparedRequest()
XCTAssertEqual(listenMessage.parse.query, "LISTEN foo;")
XCTAssertEqual(listenMessage.parse.query, #"LISTEN "foo";"#)

try await channel.writeInbound(PostgresBackendMessage.parseComplete)
try await channel.writeInbound(PostgresBackendMessage.parameterDescription(.init(dataTypes: [])))
Expand All @@ -124,7 +124,7 @@ class PostgresConnectionTests: XCTestCase {
try await channel.writeInbound(PostgresBackendMessage.notification(.init(backendPID: 12, channel: "foo", payload: "wooohooo2")))

let unlistenMessage = try await channel.waitForUnpreparedRequest()
XCTAssertEqual(unlistenMessage.parse.query, "UNLISTEN foo;")
XCTAssertEqual(unlistenMessage.parse.query, #"UNLISTEN "foo";"#)

try await channel.writeInbound(PostgresBackendMessage.parseComplete)
try await channel.writeInbound(PostgresBackendMessage.parameterDescription(.init(dataTypes: [])))
Expand Down Expand Up @@ -160,7 +160,7 @@ class PostgresConnectionTests: XCTestCase {
}

let listenMessage = try await channel.waitForUnpreparedRequest()
XCTAssertEqual(listenMessage.parse.query, "LISTEN foo;")
XCTAssertEqual(listenMessage.parse.query, #"LISTEN "foo";"#)

try await channel.writeInbound(PostgresBackendMessage.parseComplete)
try await channel.writeInbound(PostgresBackendMessage.parameterDescription(.init(dataTypes: [])))
Expand Down

0 comments on commit 0908fc7

Please sign in to comment.