From cdc4ff4ce0c113b89c1525f2db453c11d3e86581 Mon Sep 17 00:00:00 2001 From: Carlo Nyte <8445082+whoiscarlo@users.noreply.github.com> Date: Sun, 14 Jan 2024 14:03:22 -0500 Subject: [PATCH] Fix malformed array literal cause by Contains & ContainedBy func --- filterbuilder.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/filterbuilder.go b/filterbuilder.go index 8977769..019c94f 100644 --- a/filterbuilder.go +++ b/filterbuilder.go @@ -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 }