Skip to content

Commit 7f58d88

Browse files
authored
fix(http): inject filter in http controler (#370)
* fix(http): inject filter in http controler * test(http): bad filter parameter * test(http): smaller id
1 parent 75e3fff commit 7f58d88

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Types of changes
1414
- `Fixed` for any bug fixes.
1515
- `Security` in case of vulnerabilities.
1616

17+
## [3.2.1]
18+
19+
- `Fixed`Filter Parameter Not Working in "lino http" Command [#369](https://github.com/CGI-FR/LINO/issues/369)
20+
1721
## [3.2.0]
1822

1923
- `Added` flag `log-sql` (short `l`) to the push command

internal/app/pull/http.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func HandlerFactory(ingressDescriptor string) func(w http.ResponseWriter, r *htt
3636
datasourceName string
3737
ok bool
3838
distinct bool
39-
filter map[string]string
39+
filter pull.Row
4040
limit uint
4141
where string
4242
)
@@ -45,7 +45,7 @@ func HandlerFactory(ingressDescriptor string) func(w http.ResponseWriter, r *htt
4545

4646
query := r.URL.Query()
4747

48-
filter = map[string]string{}
48+
filter = pull.Row{}
4949

5050
if query.Get("filter") != "" {
5151
for _, f := range strings.Split(query.Get("filter"), ",") {
@@ -142,7 +142,7 @@ func HandlerFactory(ingressDescriptor string) func(w http.ResponseWriter, r *htt
142142
pullExporter := pullExporterFactory(w)
143143
puller := pull.NewPuller(plan, datasource, pullExporter, pull.NoTraceListener{})
144144

145-
e3 := puller.Pull(start, pull.Filter{Limit: limit, Values: pull.Row{}, Where: where, Distinct: distinct}, startSelect, nil, nil)
145+
e3 := puller.Pull(start, pull.Filter{Limit: limit, Values: filter, Where: where, Distinct: distinct}, startSelect, nil, nil)
146146
if e3 != nil {
147147
log.Error().Err(e3).Msg("")
148148
w.WriteHeader(http.StatusInternalServerError)

tests/suites/http/pull.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,19 @@ testcases:
6868
steps:
6969
- type: http
7070
method: GET
71-
url: http://lino:8000/api/v1/data/source?filter=address_id:1
71+
url: http://lino:8000/api/v1/data/source?filter=address_id:2
7272
assertions:
7373
- result.statuscode ShouldEqual 200
74-
- result.bodyjson.address_id ShouldEqual 1
74+
- result.bodyjson.address_id ShouldEqual 2
75+
76+
- name: pull filter empty
77+
steps:
78+
- type: http
79+
method: GET
80+
url: http://lino:8000/api/v1/data/source?filter=address_id:99
81+
assertions:
82+
- result.statuscode ShouldEqual 200
83+
- result.body ShouldBeEmpty
7584

7685
- name: pull filter multi values
7786
steps:

0 commit comments

Comments
 (0)