From 9becdfa8a331b29980640a8d0c3371bab38c7a72 Mon Sep 17 00:00:00 2001 From: ziggie Date: Sat, 21 Feb 2026 16:58:31 +0100 Subject: [PATCH] sqldb/sqlc: remove deprecated FilterInvoices query All call sites have been migrated to the targeted replacement queries in the previous commit. Remove FilterInvoices and its associated params struct from the SQL source and regenerate. --- sqldb/sqlc/invoices.sql.go | 111 -------------------------------- sqldb/sqlc/querier.go | 1 - sqldb/sqlc/queries/invoices.sql | 42 ------------ 3 files changed, 154 deletions(-) diff --git a/sqldb/sqlc/invoices.sql.go b/sqldb/sqlc/invoices.sql.go index d9d57cae7..911c4e1d1 100644 --- a/sqldb/sqlc/invoices.sql.go +++ b/sqldb/sqlc/invoices.sql.go @@ -123,117 +123,6 @@ func (q *Queries) FetchPendingInvoices(ctx context.Context, arg FetchPendingInvo return items, nil } -const filterInvoices = `-- name: FilterInvoices :many -SELECT - invoices.id, invoices.hash, invoices.preimage, invoices.settle_index, invoices.settled_at, invoices.memo, invoices.amount_msat, invoices.cltv_delta, invoices.expiry, invoices.payment_addr, invoices.payment_request, invoices.payment_request_hash, invoices.state, invoices.amount_paid_msat, invoices.is_amp, invoices.is_hodl, invoices.is_keysend, invoices.created_at -FROM invoices -WHERE ( - id >= $1 OR - $1 IS NULL -) AND ( - id <= $2 OR - $2 IS NULL -) AND ( - settle_index >= $3 OR - $3 IS NULL -) AND ( - settle_index <= $4 OR - $4 IS NULL -) AND ( - state = $5 OR - $5 IS NULL -) AND ( - created_at >= $6 OR - $6 IS NULL -) AND ( - created_at < $7 OR - $7 IS NULL -) AND ( - CASE - WHEN $8 = TRUE THEN (state = 0 OR state = 3) - ELSE TRUE - END -) -ORDER BY -CASE - WHEN $9 = FALSE OR $9 IS NULL THEN id - ELSE NULL - END ASC, -CASE - WHEN $9 = TRUE THEN id - ELSE NULL -END DESC -LIMIT $11 OFFSET $10 -` - -type FilterInvoicesParams struct { - AddIndexGet sql.NullInt64 - AddIndexLet sql.NullInt64 - SettleIndexGet sql.NullInt64 - SettleIndexLet sql.NullInt64 - State sql.NullInt16 - CreatedAfter sql.NullTime - CreatedBefore sql.NullTime - PendingOnly interface{} - Reverse interface{} - NumOffset int32 - NumLimit int32 -} - -func (q *Queries) FilterInvoices(ctx context.Context, arg FilterInvoicesParams) ([]Invoice, error) { - rows, err := q.db.QueryContext(ctx, filterInvoices, - arg.AddIndexGet, - arg.AddIndexLet, - arg.SettleIndexGet, - arg.SettleIndexLet, - arg.State, - arg.CreatedAfter, - arg.CreatedBefore, - arg.PendingOnly, - arg.Reverse, - arg.NumOffset, - arg.NumLimit, - ) - if err != nil { - return nil, err - } - defer rows.Close() - var items []Invoice - for rows.Next() { - var i Invoice - if err := rows.Scan( - &i.ID, - &i.Hash, - &i.Preimage, - &i.SettleIndex, - &i.SettledAt, - &i.Memo, - &i.AmountMsat, - &i.CltvDelta, - &i.Expiry, - &i.PaymentAddr, - &i.PaymentRequest, - &i.PaymentRequestHash, - &i.State, - &i.AmountPaidMsat, - &i.IsAmp, - &i.IsHodl, - &i.IsKeysend, - &i.CreatedAt, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - const filterInvoicesByAddIndex = `-- name: FilterInvoicesByAddIndex :many SELECT invoices.id, invoices.hash, invoices.preimage, invoices.settle_index, invoices.settled_at, invoices.memo, invoices.amount_msat, invoices.cltv_delta, invoices.expiry, invoices.payment_addr, invoices.payment_request, invoices.payment_request_hash, invoices.state, invoices.amount_paid_msat, invoices.is_amp, invoices.is_hodl, invoices.is_keysend, invoices.created_at diff --git a/sqldb/sqlc/querier.go b/sqldb/sqlc/querier.go index 6e0011a7d..5500c0651 100644 --- a/sqldb/sqlc/querier.go +++ b/sqldb/sqlc/querier.go @@ -36,7 +36,6 @@ type Querier interface { // fast index scan rather than a full table scan. FetchPendingInvoices(ctx context.Context, arg FetchPendingInvoicesParams) ([]Invoice, error) FetchSettledAMPSubInvoices(ctx context.Context, arg FetchSettledAMPSubInvoicesParams) ([]FetchSettledAMPSubInvoicesRow, error) - FilterInvoices(ctx context.Context, arg FilterInvoicesParams) ([]Invoice, error) // FilterInvoicesByAddIndex returns invoices whose add_index (primary key id) // is greater than or equal to the given value, ordered by id. Because id is // the primary key, this is always an efficient range scan on the clustered diff --git a/sqldb/sqlc/queries/invoices.sql b/sqldb/sqlc/queries/invoices.sql index ff23a6cf0..f9b92388d 100644 --- a/sqldb/sqlc/queries/invoices.sql +++ b/sqldb/sqlc/queries/invoices.sql @@ -132,48 +132,6 @@ WHERE id <= @add_index_let ORDER BY id DESC LIMIT @num_limit OFFSET @num_offset; --- name: FilterInvoices :many -SELECT - invoices.* -FROM invoices -WHERE ( - id >= sqlc.narg('add_index_get') OR - sqlc.narg('add_index_get') IS NULL -) AND ( - id <= sqlc.narg('add_index_let') OR - sqlc.narg('add_index_let') IS NULL -) AND ( - settle_index >= sqlc.narg('settle_index_get') OR - sqlc.narg('settle_index_get') IS NULL -) AND ( - settle_index <= sqlc.narg('settle_index_let') OR - sqlc.narg('settle_index_let') IS NULL -) AND ( - state = sqlc.narg('state') OR - sqlc.narg('state') IS NULL -) AND ( - created_at >= sqlc.narg('created_after') OR - sqlc.narg('created_after') IS NULL -) AND ( - created_at < sqlc.narg('created_before') OR - sqlc.narg('created_before') IS NULL -) AND ( - CASE - WHEN sqlc.narg('pending_only') = TRUE THEN (state = 0 OR state = 3) - ELSE TRUE - END -) -ORDER BY -CASE - WHEN sqlc.narg('reverse') = FALSE OR sqlc.narg('reverse') IS NULL THEN id - ELSE NULL - END ASC, -CASE - WHEN sqlc.narg('reverse') = TRUE THEN id - ELSE NULL -END DESC -LIMIT @num_limit OFFSET @num_offset; - -- name: UpdateInvoiceState :execresult UPDATE invoices SET state = $2,