Skip to content

Commit 90a3e44

Browse files
committed
Simplify enableNotifyInsert logic by unifying SQL statement creation and always binding throttle_interval_ms.
1 parent 3da928a commit 90a3e44

File tree

1 file changed

+3
-9
lines changed
  • sqlx4k-postgres-pgmq/src/commonMain/kotlin/io/github/smyrgeorge/sqlx4k/postgres/pgmq

1 file changed

+3
-9
lines changed

sqlx4k-postgres-pgmq/src/commonMain/kotlin/io/github/smyrgeorge/sqlx4k/postgres/pgmq/PgMqClient.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,9 @@ class PgMqClient(
8383

8484
context(tx: Transaction)
8585
suspend fun enableNotifyInsert(queue: String, throttleNotifyInterval: Duration): Result<Unit> {
86-
val statement = if (throttleNotifyInterval == Duration.ZERO) {
87-
// language=SQL
88-
val sql = "SELECT pgmq.enable_notify_insert(queue_name := ?)"
89-
Statement.create(sql).bind(0, queue)
90-
} else {
91-
// language=SQL
92-
val sql = "SELECT pgmq.enable_notify_insert(queue_name := ?, throttle_interval_ms := ?)"
93-
Statement.create(sql).bind(0, queue).bind(1, throttleNotifyInterval.inWholeMilliseconds)
94-
}
86+
// language=SQL
87+
val sql = "SELECT pgmq.enable_notify_insert(queue_name := ?, throttle_interval_ms := ?)"
88+
val statement = Statement.create(sql).bind(0, queue).bind(1, throttleNotifyInterval.inWholeMilliseconds)
9589
return tx.fetchAll(statement, UnitRowMapper).toSingleUnitResult()
9690
}
9791

0 commit comments

Comments
 (0)