Skip to content

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

Remove find parameter when fetching the entire principal list since it’s always an empty list

天舟d1dcb0c8edeb
diff --git a/api/principal.go b/api/principal.go
index abea69cc30..4df5fdab3b 100644
--- a/api/principal.go
+++ b/api/principal.go
@@ -114,7 +114,7 @@ type PrincipalPatch struct {
type PrincipalService interface {
CreatePrincipal(ctx context.Context, create *PrincipalCreate) (*Principal, error)
- FindPrincipalList(ctx context.Context, find *PrincipalFind) ([]*Principal, error)
+ FindPrincipalList(ctx context.Context) ([]*Principal, error)
FindPrincipal(ctx context.Context, find *PrincipalFind) (*Principal, error)
PatchPrincipal(ctx context.Context, patch *PrincipalPatch) (*Principal, error)
}
diff --git a/server/principal.go b/server/principal.go
index 5be67e096c..1f445ec49f 100644
--- a/server/principal.go
+++ b/server/principal.go
@@ -47,7 +47,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {
})
g.GET("/principal", func(c echo.Context) error {
- list, err := s.PrincipalService.FindPrincipalList(context.Background(), &api.PrincipalFind{})
+ list, err := s.PrincipalService.FindPrincipalList(context.Background())
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch principal list").SetInternal(err)
}
diff --git a/store/principal.go b/store/principal.go
index 864ea02c0d..254cb2977f 100644
--- a/store/principal.go
+++ b/store/principal.go
@@ -46,14 +46,14 @@ func (s *PrincipalService) CreatePrincipal(ctx context.Context, create *api.Prin
}
// FindPrincipalList retrieves a list of principals.
-func (s *PrincipalService) FindPrincipalList(ctx context.Context, find *api.PrincipalFind) ([]*api.Principal, error) {
+func (s *PrincipalService) FindPrincipalList(ctx context.Context) ([]*api.Principal, error) {
tx, err := s.db.BeginTx(ctx, nil)
if err != nil {
return nil, FormatError(err)
}
defer tx.Rollback()
- list, err := findPrincipalList(ctx, tx, find)
+ list, err := findPrincipalList(ctx, tx, &api.PrincipalFind{})
if err != nil {
return []*api.Principal{}, err
}