Skip to content

Commit 4fc5847

Browse files
committed
Fix slice filter function for postgres
1 parent 8032af0 commit 4fc5847

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v4.0.1
2+
3+
- (bug) Fix slice filter function for postgres
4+
15
# v4.0.0
26

37
- (bug) Cleanup tests (postgres)

postgres/filters.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ func jsonKeyToSelector(column string, key string, value any) string {
2121
parts = parts[1:]
2222
}
2323
return lo.Reduce(parts, func(acc string, part string, i int) string {
24-
switch value.(type) {
24+
switch v := value.(type) {
2525
case string:
2626
if i == len(parts)-1 {
2727
return fmt.Sprintf("%s->>'%s'", acc, part)
2828
}
29+
case []any:
30+
if i == len(parts)-1 && len(v) > 0 {
31+
if _, ok := v[0].(string); ok {
32+
return fmt.Sprintf("%s->>'%s'", acc, part)
33+
}
34+
}
2935
}
3036
return fmt.Sprintf("%s->'%s'", acc, part)
3137
}, initial)

0 commit comments

Comments
 (0)