Skip to content

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

fix: take uid for instance listing (#4209)

Danny Xu751f378ae27a
diff --git a/store/instance.go b/store/instance.go
index 113f97dc2c..809bac9d0c 100644
--- a/store/instance.go
+++ b/store/instance.go
@@ -739,7 +739,7 @@ func (s *Store) GetInstanceV2(ctx context.Context, find *FindInstanceMessage) (*
return nil, nil
}
if len(instances) > 1 {
- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d instances with filter %+v, expect 1", len(instances), find)}
+ return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d instances with filter %#v, expect 1", len(instances), find)}
}
instance := instances[0]
@@ -1002,6 +1002,9 @@ func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstan
if v := find.ResourceID; v != nil {
where, args = append(where, fmt.Sprintf("instance.resource_id = $%d", len(args)+1)), append(args, *v)
}
+ if v := find.UID; v != nil {
+ where, args = append(where, fmt.Sprintf("instance.id = $%d", len(args)+1)), append(args, *v)
+ }
if !find.ShowDeleted {
where, args = append(where, fmt.Sprintf("instance.row_status = $%d", len(args)+1)), append(args, api.Normal)
}
diff --git a/store/principal.go b/store/principal.go
index 43d8b5750d..4b52059978 100644
--- a/store/principal.go
+++ b/store/principal.go
@@ -181,7 +181,6 @@ func (s *Store) GetUserByEmail(ctx context.Context, email string) (*UserMessage,
// GetUserByEmailV2 gets an instance of Principal.
func (*Store) listUserImpl(ctx context.Context, tx *Tx, find *FindUserMessage) ([]*UserMessage, error) {
- // TODO(d): set user role to owner for free license.
where, args := []string{"1 = 1"}, []interface{}{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("principal.id = $%d", len(args)+1)), append(args, *v)
@@ -383,7 +382,6 @@ func (s *Store) UpdateUser(ctx context.Context, userID int, patch *UpdateUserMes
}
return nil, FormatError(err)
}
- // TODO(d): use upsert for member update.
var rowStatus string
if err := tx.QueryRowContext(ctx, fmt.Sprintf(`
UPDATE member
diff --git a/store/project.go b/store/project.go
index 3caf14d4e5..320607655b 100644
--- a/store/project.go
+++ b/store/project.go
@@ -213,7 +213,7 @@ func (s *Store) GetProjectV2(ctx context.Context, find *FindProjectMessage) (*Pr
return nil, nil
}
if len(projects) > 1 {
- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d instances with filter %+v, expect 1", len(projects), find)}
+ return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d projects with filter %+v, expect 1", len(projects), find)}
}
project := projects[0]