Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix value in filter for joins (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrogan authored Apr 24, 2020
1 parent 6825482 commit b8416b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/common/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (f *inlineFilterImpl) getGormQueryExpr(formattedField string) (GormQueryExp

// ValueIn is special because it uses repeating values.
if f.function == ValueIn {
queryStr := fmt.Sprintf(valueInQuery, f.field)
queryStr := fmt.Sprintf(valueInQuery, formattedField)
return GormQueryExpr{
Query: queryStr,
Args: f.repeatedValue,
Expand Down
8 changes: 7 additions & 1 deletion pkg/common/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ func TestNewSingleValueCustomizedFilter(t *testing.T) {
}

func TestNewRepeatedValueFilter(t *testing.T) {
_, err := NewRepeatedValueFilter(Workflow, ValueIn, "project", []string{"SuperAwesomeProject", "AnotherAwesomeProject"})
vals := []string{"SuperAwesomeProject", "AnotherAwesomeProject"}
filter, err := NewRepeatedValueFilter(Workflow, ValueIn, "project", vals)
assert.NoError(t, err)

expression, err := filter.GetGormJoinTableQueryExpr("projects")
assert.NoError(t, err)
assert.Equal(t, "projects.project in (?)", expression.Query)
assert.Equal(t, vals, expression.Args)

_, err = NewRepeatedValueFilter(Workflow, Equal, "domain", []string{"production", "qa"})
assert.EqualError(t, err, "invalid repeated value filter expression: equal")
}
Expand Down
2 changes: 1 addition & 1 deletion tests/task_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestCreateAndListTaskExecution(t *testing.T) {
NodeExecutionId: nodeExecutionId,
Limit: 10,
Filters: "eq(task.project, project)+eq(task.domain, development)+eq(task.name, task name)+" +
"eq(task.version, task version)+eq(task_execution.retry_attempt, 1)",
"eq(task.version, task version)+eq(task_execution.retry_attempt, 1)+value_in(phase, RUNNING)",
})
assert.Len(t, response.TaskExecutions, 1)
assert.Nil(t, err)
Expand Down

0 comments on commit b8416b5

Please sign in to comment.