Skip to content

Commit

Permalink
Fix malformed array literal cause by Contains & ContainedBy functions #…
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufpapurcu authored Jan 28, 2024
2 parents f84277b + cdc4ff4 commit 7cc315c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions filterbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,26 @@ func (f *FilterBuilder) In(column string, values []string) *FilterBuilder {
}

func (f *FilterBuilder) Contains(column string, value []string) *FilterBuilder {
f.params[column] = "cs." + strings.Join(value, ",")
newValue := []string{}
for _, v := range value {
newValue = append(newValue, fmt.Sprintf("%#v", v))
}

valueString := fmt.Sprintf("{%s}", strings.Join(newValue, ","))

f.params[column] = "cs." + valueString
return f
}

func (f *FilterBuilder) ContainedBy(column string, value []string) *FilterBuilder {
f.params[column] = "cd." + strings.Join(value, ",")
newValue := []string{}
for _, v := range value {
newValue = append(newValue, fmt.Sprintf("%#v", v))
}

valueString := fmt.Sprintf("{%s}", strings.Join(newValue, ","))

f.params[column] = "cd." + valueString
return f
}

Expand Down

0 comments on commit 7cc315c

Please sign in to comment.