Skip to content

Commit c61095c

Browse files
authored
Merge pull request #9879 from ellemouton/graphSQLFixNodesQuery
sqldb+graph/db: fix UpsertNode query to account for nullable `last_update` field
2 parents f8e67c0 + 547b836 commit c61095c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

graph/db/graph_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3359,6 +3359,9 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
33593359
// error.
33603360
err = graph.AddChannelEdge(&edgeInfo)
33613361
require.ErrorIs(t, err, ErrEdgeAlreadyExist)
3362+
3363+
// Show that updating the shell node to a full node record works.
3364+
require.NoError(t, graph.AddLightningNode(node2))
33623365
}
33633366

33643367
// TestNodePruningUpdateIndexDeletion tests that once a node has been removed

sqldb/sqlc/graph.sql.go

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

sqldb/sqlc/queries/graph.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ ON CONFLICT (pub_key, version)
1717
last_update = EXCLUDED.last_update,
1818
color = EXCLUDED.color,
1919
signature = EXCLUDED.signature
20-
WHERE EXCLUDED.last_update > nodes.last_update
20+
WHERE nodes.last_update IS NULL
21+
OR EXCLUDED.last_update > nodes.last_update
2122
RETURNING id;
2223

2324
-- name: GetNodeByPubKey :one

0 commit comments

Comments
 (0)