fix: action query (#4257)

This commit is contained in:
Livio Spring 2022-08-26 10:38:41 +02:00 committed by GitHub
parent cbb5e90bac
commit e1a981928c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -111,9 +111,13 @@ func ActionStateToPb(state domain.ActionState) action_pb.ActionState {
func ActionNameQuery(q *action_pb.ActionNameQuery) (query.SearchQuery, error) {
return query.NewActionNameSearchQuery(object_grpc.TextMethodToQuery(q.Method), q.Name)
}
func ActionStateQuery(q *action_pb.ActionStateQuery) (query.SearchQuery, error) {
return query.NewActionStateSearchQuery(ActionStateToDomain(q.State))
}
func ActionIDQuery(q *action_pb.ActionIDQuery) (query.SearchQuery, error) {
return query.NewActionIDSearchQuery(q.Id)
}
func ActionStateToDomain(state action_pb.ActionState) domain.ActionState {
switch state {

View File

@ -4,6 +4,7 @@ import (
action_grpc "github.com/zitadel/zitadel/internal/api/grpc/action"
"github.com/zitadel/zitadel/internal/api/grpc/object"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
"github.com/zitadel/zitadel/internal/query"
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
@ -59,6 +60,8 @@ func ActionQueryToQuery(query interface{}) (query.SearchQuery, error) {
return action_grpc.ActionNameQuery(q.ActionNameQuery)
case *mgmt_pb.ActionQuery_ActionStateQuery:
return action_grpc.ActionStateQuery(q.ActionStateQuery)
case *mgmt_pb.ActionQuery_ActionIdQuery:
return action_grpc.ActionIDQuery(q.ActionIdQuery)
}
return nil, nil
return nil, errors.ThrowInvalidArgument(nil, "MGMT-dsg3z", "Errors.Query.InvalidRequest")
}

View File

@ -148,6 +148,10 @@ func NewActionStateSearchQuery(value domain.ActionState) (SearchQuery, error) {
return NewNumberQuery(ActionColumnState, int(value), NumberEquals)
}
func NewActionIDSearchQuery(id string) (SearchQuery, error) {
return NewTextQuery(ActionColumnID, id, TextEquals)
}
func prepareActionsQuery() (sq.SelectBuilder, func(rows *sql.Rows) (*Actions, error)) {
return sq.Select(
ActionColumnID.identifier(),