sqldb/sqlc: remove deprecated FilterInvoices query
What changed, and why it matters
This commit simply deletes an unused database query called FilterInvoices and its supporting code. The commit message says all places that used it have already been switched to newer, more targeted queries. There is no security issue visible in this change; it is routine code cleanup.
No security action needed. Verify that the previous commit did correctly migrate all call sites and that no references to FilterInvoices remain in the codebase.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes the deprecated FilterInvoices SQLC query, its generated Go implementation, and its params struct. The query was a broad, multi-parameter invoice filter. The commit message states call sites were migrated to replacement queries in the prior commit. No functional change or vulnerability is introduced by this deletion; it reduces dead code.
Changed components
sqldb/sqlc/invoices.sql.gosqldb/sqlc/querier.gosqldb/sqlc/queries/invoices.sqlInspect captured patch +0 / −154
diff --git a/sqldb/sqlc/invoices.sql.go b/sqldb/sqlc/invoices.sql.go
index d9d57ca..911c4e1 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 6e0011a..5500c06 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 ff23a6c..f9b9238 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,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.