graph/db+sqldb: remove LEFT JOIN for fetching node addresses

In this commit, we remove the LEFT JOIN query that was used for fetching
a nodes addresses. The reason it was used before was to ensure that we'd
get an empty address list if the node did exist but had no addresses.
This was for the purposes of the `AddrsForNode` method since it needs to
return false/true to indicate if the given node exists.
This commit is contained in:
Elle Mouton
2025-07-28 10:17:56 +02:00
parent 43db6683d2
commit 5a1184c664
4 changed files with 54 additions and 67 deletions

View File

@@ -134,12 +134,11 @@ INSERT INTO graph_node_addresses (
$1, $2, $3, $4
);
-- name: GetNodeAddressesByPubKey :many
SELECT a.type, a.address
FROM graph_nodes n
LEFT JOIN graph_node_addresses a ON a.node_id = n.id
WHERE n.pub_key = $1 AND n.version = $2
ORDER BY a.type ASC, a.position ASC;
-- name: GetNodeAddresses :many
SELECT type, address
FROM graph_node_addresses
WHERE node_id = $1
ORDER BY type ASC, position ASC;
-- name: GetNodesByLastUpdateRange :many
SELECT *