From 5f30fd792a817d2b053f66b97b1b060cea27c6b4 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Thu, 5 May 2022 16:41:05 -0400 Subject: [PATCH] No Settled Transactions is 0, not Null Unexpectedly this doesn't return either no columns or a column with a value of 0, but instead a column with no value... --- lib/trust_level_repo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/trust_level_repo.rb b/lib/trust_level_repo.rb index 61e9925..74fbecb 100644 --- a/lib/trust_level_repo.rb +++ b/lib/trust_level_repo.rb @@ -27,7 +27,7 @@ protected def fetch_settled_amount(customer_id) db.query_one(<<~SQL, customer_id, default: {}) - SELECT SUM(amount) AS settled_amount FROM transactions + SELECT COALESCE(SUM(amount), 0) AS settled_amount FROM transactions WHERE customer_id=$1 AND settled_after < LOCALTIMESTAMP AND amount > 0 SQL end -- 2.45.2