From d3cc6a2895889a782508006653637d860e384574 Mon Sep 17 00:00:00 2001 From: "marko.tikvic" Date: Wed, 24 Oct 2018 15:32:38 +0200 Subject: [PATCH] < > filtering --- filtering.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- 1.8.1.2