sqldb+invoices: synchronize SQL invoice updater behavior with KV version

Previously SQL invoice updater ignored the set ID hint when updating an
AMP invoice resulting in update subscriptions returning all of the AMP
state as well as all AMP HTLCs. This commit synchornizes behavior with
the KV implementation such that we now only return relevant AMP state
and HTLCs when updating an AMP invoice.
This commit is contained in:
Andras Banki-Horvath committed 2024-09-03 19:40:46 +02:00
1 parent c8de7a1699
commit b57910ee3a
4 files changed
+106 -18

No files matched your search

+11 -4
View File
@@ -26,7 +26,11 @@ WHERE invoice_id = $1;
-- name: GetInvoice :many
SELECT i.*
FROM invoices i
LEFT JOIN amp_sub_invoices a on i.id = a.invoice_id
LEFT JOIN amp_sub_invoices a
ON i.id = a.invoice_id
AND (
a.set_id = sqlc.narg('set_id') OR sqlc.narg('set_id') IS NULL
)
WHERE (
i.id = sqlc.narg('add_index') OR
sqlc.narg('add_index') IS NULL
@@ -39,13 +43,16 @@ WHERE (
) AND (
i.payment_addr = sqlc.narg('payment_addr') OR
sqlc.narg('payment_addr') IS NULL
) AND (
a.set_id = sqlc.narg('set_id') OR
sqlc.narg('set_id') IS NULL
)
GROUP BY i.id
LIMIT 2;
-- name: GetInvoiceBySetID :many
SELECT i.*
FROM invoices i
INNER JOIN amp_sub_invoices a
ON i.id = a.invoice_id AND a.set_id = $1;
-- name: FilterInvoices :many
SELECT
invoices.*