fix: return flow type (#2563)

This commit is contained in:
Livio Amstutz 2021-10-22 16:45:30 +02:00 committed by GitHub
parent f5661c6e61
commit 686c0edb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,7 @@ type Flow struct {
} }
func (q *Queries) GetFlow(ctx context.Context, flowType domain.FlowType, orgID string) (*Flow, error) { func (q *Queries) GetFlow(ctx context.Context, flowType domain.FlowType, orgID string) (*Flow, error) {
query, scan := q.prepareFlowQuery() query, scan := q.prepareFlowQuery(flowType)
stmt, args, err := query.Where( stmt, args, err := query.Where(
sq.Eq{ sq.Eq{
FlowsTriggersColumnFlowType.identifier(): flowType, FlowsTriggersColumnFlowType.identifier(): flowType,
@ -172,7 +172,7 @@ func (q *Queries) prepareTriggerActionsQuery() (sq.SelectBuilder, func(*sql.Rows
} }
} }
func (q *Queries) prepareFlowQuery() (sq.SelectBuilder, func(*sql.Rows) (*Flow, error)) { func (q *Queries) prepareFlowQuery(flowType domain.FlowType) (sq.SelectBuilder, func(*sql.Rows) (*Flow, error)) {
return sq.Select( return sq.Select(
ActionColumnID.identifier(), ActionColumnID.identifier(),
ActionColumnCreationDate.identifier(), ActionColumnCreationDate.identifier(),
@ -190,6 +190,7 @@ func (q *Queries) prepareFlowQuery() (sq.SelectBuilder, func(*sql.Rows) (*Flow,
PlaceholderFormat(sq.Dollar), PlaceholderFormat(sq.Dollar),
func(rows *sql.Rows) (*Flow, error) { func(rows *sql.Rows) (*Flow, error) {
flow := &Flow{ flow := &Flow{
Type: flowType,
TriggerActions: make(map[domain.TriggerType][]*Action), TriggerActions: make(map[domain.TriggerType][]*Action),
} }
for rows.Next() { for rows.Next() {