mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-26 10:09:50 +00:00
Added quotes to listen/unlisten channel names to honor case sensitivity and be consistent with 'listen_all()'
This commit is contained in:
parent
9b68eb19ef
commit
a0d1106f90
@ -51,6 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
async fn notify(mut pool: &PgPool) {
|
||||
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
// Note that channel names are lower-cased by Postgres unless they are quoted
|
||||
let res = pool
|
||||
.execute(&*format!(
|
||||
r#"
|
||||
|
||||
@ -64,9 +64,10 @@ impl PgListener {
|
||||
}
|
||||
|
||||
/// Starts listening for notifications on a channel.
|
||||
/// The channel name is quoted here to ensure case sensitivity.
|
||||
pub async fn listen(&mut self, channel: &str) -> Result<(), Error> {
|
||||
self.connection()
|
||||
.execute(&*format!("LISTEN {}", ident(channel)))
|
||||
.execute(&*format!(r#"LISTEN "{}""#, ident(channel)))
|
||||
.await?;
|
||||
|
||||
self.channels.push(channel.to_owned());
|
||||
@ -92,9 +93,10 @@ impl PgListener {
|
||||
}
|
||||
|
||||
/// Stops listening for notifications on a channel.
|
||||
/// The channel name is quoted here to ensure case sensitivity.
|
||||
pub async fn unlisten(&mut self, channel: &str) -> Result<(), Error> {
|
||||
self.connection()
|
||||
.execute(&*format!("UNLISTEN {}", ident(channel)))
|
||||
.execute(&*format!(r#"UNLISTEN "{}""#, ident(channel)))
|
||||
.await?;
|
||||
|
||||
if let Some(pos) = self.channels.iter().position(|s| s == channel) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user