Commit d3cc6a2895889a782508006653637d860e384574
1 parent
564ef69718
Exists in
master
< > filtering
Showing
1 changed file
with
11 additions
and
1 deletions
Show diff stats
filtering.go
... | ... | @@ -50,6 +50,7 @@ func ParseFilters(req *http.Request, header string) (filters Filter) { |
50 | 50 | return filters |
51 | 51 | } |
52 | 52 | |
53 | +// TODO(marko): very dodgy, needs more robustness | |
53 | 54 | func MakeFilterString(prefix string, filters Filter, validFilters []string) (res string, ok bool) { |
54 | 55 | if prefix != "" { |
55 | 56 | prefix += "." |
... | ... | @@ -63,13 +64,22 @@ func MakeFilterString(prefix string, filters Filter, validFilters []string) (res |
63 | 64 | return "", ok |
64 | 65 | } |
65 | 66 | |
67 | + symbol := "=" | |
66 | 68 | for k, v := range filters { |
67 | 69 | if res != "" { |
68 | 70 | res += " and " |
69 | 71 | } else { |
70 | 72 | res += " where " |
71 | 73 | } |
72 | - res += fmt.Sprintf("%s%s = '%s'", prefix, k, v) | |
74 | + c := string(v[0]) | |
75 | + if c == "<" || c == ">" { | |
76 | + symbol = c | |
77 | + v = string(v[1:]) | |
78 | + } else { | |
79 | + symbol = "=" | |
80 | + } | |
81 | + | |
82 | + res += fmt.Sprintf("%s%s %s '%s'", prefix, k, symbol, v) | |
73 | 83 | } |
74 | 84 | |
75 | 85 | return res, ok | ... | ... |