diff --git a/cala-ledger/src/atomic_operation.rs b/cala-ledger/src/atomic_operation.rs index d3823f2f..b410c19f 100644 --- a/cala-ledger/src/atomic_operation.rs +++ b/cala-ledger/src/atomic_operation.rs @@ -30,9 +30,13 @@ impl<'a> AtomicOperation<'a> { } pub async fn commit(self) -> Result<(), sqlx::Error> { - self.outbox - .persist_events(self.tx, self.accumulated_events) - .await?; + if self.accumulated_events.is_empty() { + self.tx.commit().await?; + } else { + self.outbox + .persist_events(self.tx, self.accumulated_events) + .await?; + } Ok(()) } }