diff --git a/filtering.go b/filtering.go index ec68510..4f11fa4 100644 --- a/filtering.go +++ b/filtering.go @@ -50,6 +50,7 @@ func ParseFilters(req *http.Request, header string) (filters Filter) { return filters } +// TODO(marko): very dodgy, needs more robustness func MakeFilterString(prefix string, filters Filter, validFilters []string) (res string, ok bool) { if prefix != "" { prefix += "." @@ -63,13 +64,22 @@ func MakeFilterString(prefix string, filters Filter, validFilters []string) (res return "", ok } + symbol := "=" for k, v := range filters { if res != "" { res += " and " } else { res += " where " } - res += fmt.Sprintf("%s%s = '%s'", prefix, k, v) + c := string(v[0]) + if c == "<" || c == ">" { + symbol = c + v = string(v[1:]) + } else { + symbol = "=" + } + + res += fmt.Sprintf("%s%s %s '%s'", prefix, k, symbol, v) } return res, ok