Skip to content

Commit

Permalink
refactor: replace format with bind in sqlx query
Browse files Browse the repository at this point in the history
  • Loading branch information
hamirmahal committed Nov 13, 2024
1 parent 8aa9192 commit f52bddc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pgmq-rs/src/pg_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ impl PGMQueueExt {
let queue_table = format!("pgmq.{QUEUE_PREFIX}_{queue_name}");
// we need to check whether the queue exists first
// pg_partman create operations are currently unable to be idempotent
let exists_stmt = format!(
"SELECT EXISTS(SELECT * from part_config where parent_table = '{queue_table}');"
);
let exists = sqlx::query_scalar(&exists_stmt).fetch_one(executor).await?;
let exists_stmt = "SELECT EXISTS(SELECT * from part_config where parent_table = $1);";
let exists = sqlx::query_scalar(exists_stmt)
.bind(queue_table)
.fetch_one(executor)
.await?;
if exists {
info!("queue: {} already exists", queue_name);
Ok(false)
Expand Down

0 comments on commit f52bddc

Please sign in to comment.