Skip to content

Commit

Permalink
zcash_client_sqlite: Fix add_account_uuids migration
Browse files Browse the repository at this point in the history
`v_tx_outputs` gains new JOINs on `accounts.id` in order to migrate to
exposing `accounts.uuid`, but as there are two table joins the tables
are given aliases. The aliases were not being used in the JOIN's ON
condition, leading to an error when querying the view.
  • Loading branch information
str4d committed Dec 9, 2024
1 parent 3725313 commit 5c404a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions zcash_client_sqlite/src/wallet/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ JOIN transactions
-- join to the sent_notes table to obtain `from_account_id`
LEFT JOIN sent_notes ON sent_notes.id = ro.sent_note_id
-- join on the accounts table to obtain account UUIDs
JOIN accounts from_account ON accounts.id = sent_notes.from_account_id
JOIN accounts to_account ON accounts.id = ro.account_id
JOIN accounts from_account ON from_account.id = sent_notes.from_account_id
JOIN accounts to_account ON to_account.id = ro.account_id
UNION
-- select all outputs sent from the wallet to external recipients
SELECT transactions.txid AS txid,
Expand All @@ -918,7 +918,7 @@ JOIN transactions
ON transactions.id_tx = sent_notes.tx
LEFT JOIN v_received_outputs ro ON ro.sent_note_id = sent_notes.id
-- join on the accounts table to obtain account UUIDs
JOIN accounts from_account ON accounts.id = sent_notes.from_account_id
JOIN accounts from_account ON from_account.id = sent_notes.from_account_id
-- exclude any sent notes for which a row exists in the v_received_outputs view
WHERE ro.account_id IS NULL";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ impl RusqliteMigration for Migration {
-- join to the sent_notes table to obtain `from_account_id`
LEFT JOIN sent_notes ON sent_notes.id = ro.sent_note_id
-- join on the accounts table to obtain account UUIDs
JOIN accounts from_account ON accounts.id = sent_notes.from_account_id
JOIN accounts to_account ON accounts.id = ro.account_id
JOIN accounts from_account ON from_account.id = sent_notes.from_account_id
JOIN accounts to_account ON to_account.id = ro.account_id
UNION
-- select all outputs sent from the wallet to external recipients
SELECT transactions.txid AS txid,
Expand All @@ -307,7 +307,7 @@ impl RusqliteMigration for Migration {
ON transactions.id_tx = sent_notes.tx
LEFT JOIN v_received_outputs ro ON ro.sent_note_id = sent_notes.id
-- join on the accounts table to obtain account UUIDs
JOIN accounts from_account ON accounts.id = sent_notes.from_account_id
JOIN accounts from_account ON from_account.id = sent_notes.from_account_id
-- exclude any sent notes for which a row exists in the v_received_outputs view
WHERE ro.account_id IS NULL",
)?;
Expand Down

0 comments on commit 5c404a3

Please sign in to comment.