Skip to content

Commit 87ca58f

Browse files
committed
WIP
1 parent fd84f6f commit 87ca58f

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

tapdb/sqlc/assets.sql.go

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

tapdb/sqlc/querier.go

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

tapdb/sqlc/queries/assets.sql

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,26 +1064,28 @@ ORDER BY assets_meta.meta_id;
10641064

10651065
-- name: UpsertSupplyPreCommit :one
10661066
-- Upsert a record into the supply_pre_commits table.
1067-
-- If a record with the same batch ID and tx output index already exists, update
1068-
-- the existing record. Otherwise, insert a new record.
1067+
-- If a record with the same outpoint exists, update it; otherwise insert a new
1068+
-- record.
10691069
WITH target_batch AS (
1070-
-- This CTE is used to fetch the ID of a batch, based on the serialized
1071-
-- internal key associated with the batch.
10721070
SELECT keys.key_id AS batch_id
1073-
FROM internal_keys keys
1071+
FROM internal_keys AS keys
10741072
WHERE keys.raw_key = @batch_key
10751073
)
10761074
INSERT INTO supply_pre_commits (
1077-
batch_id, tx_output_index, taproot_internal_key_id, group_key, spent_by, outpoint
1075+
batch_id, tx_output_index, taproot_internal_key_id, group_key, spent_by,
1076+
outpoint
10781077
)
10791078
VALUES (
1080-
(SELECT batch_id FROM target_batch), @tx_output_index,
1081-
@taproot_internal_key_id, @group_key, sqlc.narg('spent_by'), sqlc.narg('outpoint')
1079+
(SELECT batch_id FROM target_batch), @tx_output_index,
1080+
@taproot_internal_key_id, @group_key, sqlc.narg('spent_by'),
1081+
sqlc.narg('outpoint')
10821082
)
1083-
ON CONFLICT(batch_id, tx_output_index) DO UPDATE SET
1084-
-- The following fields are updated if a conflict occurs.
1083+
ON CONFLICT(outpoint) DO UPDATE SET
1084+
batch_id = EXCLUDED.batch_id,
1085+
tx_output_index = EXCLUDED.tx_output_index,
10851086
taproot_internal_key_id = EXCLUDED.taproot_internal_key_id,
10861087
group_key = EXCLUDED.group_key,
1088+
spent_by = EXCLUDED.spent_by,
10871089
outpoint = EXCLUDED.outpoint
10881090
RETURNING id;
10891091

0 commit comments

Comments
 (0)