diff --git a/db/nodes.go b/db/nodes.go index a602cb3..cff1210 100644 --- a/db/nodes.go +++ b/db/nodes.go @@ -127,6 +127,7 @@ func (s *Store) ListNodes(ctx context.Context, nodeType int16, iatas []string, s Longitude: v.Longitude, IsObserver: v.IsObserver, ObserverID: nullableUUID(v.ObserverID), + DefaultScope: v.DefaultScopeName, KnownNeighborCount: v.KnownNeighborCount, NeighborIDs: v.NeighborIds, Stale: v.LastSeen.Valid && v.LastSeen.Time.Before(time.Now().Add(-s.staleThreshold)), diff --git a/db/nodes_test.go b/db/nodes_test.go index db9a0dd..590c08c 100644 --- a/db/nodes_test.go +++ b/db/nodes_test.go @@ -706,3 +706,15 @@ func TestDeleteOldNodes(t *testing.T) { t.Fatalf("unexpected error: %v", err) } } + +func TestListNodes_DefaultScopePreservesCaseAndMissingValue(t *testing.T) { + ctrl := gomock.NewController(t) + mock := mockdb.NewMockQuerier(ctrl) + scope := "#YOW" + mock.EXPECT().ListNodes(gomock.Any(), gomock.Any()).Return([]sqlc.ListNodesRow{{DefaultScopeName: &scope}, {}}, nil) + store := &Store{q: mock} + page, err := store.ListNodes(context.Background(), 0, nil, nil, nil, nil, "", "", "", 0, 10, false) + if err != nil || len(page.Items) != 2 || page.Items[0].DefaultScope == nil || *page.Items[0].DefaultScope != scope || page.Items[1].DefaultScope != nil { + t.Fatalf("scope metadata lost or invented: %+v %v", page, err) + } +}