Skip to content

Commit e47f08f

Browse files
committed
multi: add UpdateAccountAliasForTests query
In the upcoming kvdb to SQL migration of the actions store, we need to simulate in tests that two or more accounts have colliding account aliases for the first 4 bytes of the alias. In order to allow creation of such accounts, we need to be able to update the alias of an account in tests, and this commit adds the a SQL query enabling this functionality. Note that the `UpdateAccountAliasForTests` query is only intended for use in tests and should not be used in production code.
1 parent fd674dd commit e47f08f

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

accounts/store_sql.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ type SQLQueries interface {
4949
UpdateAccountBalance(ctx context.Context, arg sqlc.UpdateAccountBalanceParams) (int64, error)
5050
UpdateAccountExpiry(ctx context.Context, arg sqlc.UpdateAccountExpiryParams) (int64, error)
5151
UpdateAccountLastUpdate(ctx context.Context, arg sqlc.UpdateAccountLastUpdateParams) (int64, error)
52+
// UpdateAccountAliasForTests is a query intended only for testing
53+
// purposes, to change the account alias.
54+
UpdateAccountAliasForTests(ctx context.Context, arg sqlc.UpdateAccountAliasForTestsParams) (int64, error)
5255
UpsertAccountPayment(ctx context.Context, arg sqlc.UpsertAccountPaymentParams) error
5356
GetAccountInvoice(ctx context.Context, arg sqlc.GetAccountInvoiceParams) (sqlc.AccountInvoice, error)
5457
}

db/sqlc/accounts.sql.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/sqlc/querier.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db/sqlc/queries/accounts.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ RETURNING id;
2525
INSERT INTO account_invoices (account_id, hash)
2626
VALUES ($1, $2);
2727

28+
-- name: UpdateAccountAliasForTests :one
29+
-- NOTE: This query is only intended for testing purposes.
30+
UPDATE accounts
31+
SET alias = $1
32+
WHERE id = $2
33+
RETURNING id;
34+
2835
-- name: DeleteAccountPayment :exec
2936
DELETE FROM account_payments
3037
WHERE hash = $1

0 commit comments

Comments
 (0)