Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: find changelists across projects (#8460)

Danny Xu573bb922be43
diff --git a/backend/api/v1/changelist_service.go b/backend/api/v1/changelist_service.go
index 7e77b312ff..2e2540b6af 100644
--- a/backend/api/v1/changelist_service.go
+++ b/backend/api/v1/changelist_service.go
@@ -101,20 +101,24 @@ func (s *ChangelistService) ListChangelists(ctx context.Context, request *v1pb.L
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, err.Error())
}
- project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
- ResourceID: &projectResourceID,
- })
- if err != nil {
- return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to get project with resource id %q, err: %s", projectResourceID, err.Error()))
- }
- if project == nil {
- return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q not found", projectResourceID))
- }
- if project.Deleted {
- return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q had deleted", projectResourceID))
- }
- changelists, err := s.store.ListChangelists(ctx, &store.FindChangelistMessage{ProjectID: &project.ResourceID})
+ find := &store.FindChangelistMessage{}
+ if projectResourceID != "-" {
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectResourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, fmt.Sprintf("failed to get project with resource id %q, err: %s", projectResourceID, err.Error()))
+ }
+ if project == nil {
+ return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q not found", projectResourceID))
+ }
+ if project.Deleted {
+ return nil, status.Errorf(codes.NotFound, fmt.Sprintf("project with resource id %q had deleted", projectResourceID))
+ }
+ find.ProjectID = &projectResourceID
+ }
+ changelists, err := s.store.ListChangelists(ctx, find)
if err != nil {
return nil, err
}