diff --git a/tools/search/filter.go b/tools/search/filter.go index 747d586f..29539ebb 100644 --- a/tools/search/filter.go +++ b/tools/search/filter.go @@ -147,11 +147,17 @@ func (f FilterData) resolveToken(token fexpr.Token, fieldResolver FieldResolver) } return name, params, err - case fexpr.TokenNumber, fexpr.TokenText: + case fexpr.TokenText: placeholder := "t" + security.RandomString(7) name := fmt.Sprintf("{:%s}", placeholder) params := dbx.Params{placeholder: token.Literal} + return name, params, nil + case fexpr.TokenNumber: + placeholder := "t" + security.RandomString(7) + name := fmt.Sprintf("{:%s}", placeholder) + params := dbx.Params{placeholder: cast.ToFloat64(token.Literal)} + return name, params, nil } diff --git a/tools/search/provider_test.go b/tools/search/provider_test.go index ed5ee563..be77daf8 100644 --- a/tools/search/provider_test.go +++ b/tools/search/provider_test.go @@ -288,8 +288,8 @@ func TestProviderExecNonEmptyQuery(t *testing.T) { false, `{"page":1,"perPage":` + fmt.Sprint(MaxPerPage) + `,"totalItems":1,"items":[{"test1":2,"test2":"test2.2","test3":""}]}`, []string{ - "SELECT COUNT(*) FROM `test` WHERE ((NOT (`test1` IS NULL)) AND (COALESCE(test2, '') != COALESCE(null, ''))) AND (test1 >= '2') ORDER BY `test1` ASC, `test2` DESC", - "SELECT * FROM `test` WHERE ((NOT (`test1` IS NULL)) AND (COALESCE(test2, '') != COALESCE(null, ''))) AND (test1 >= '2') ORDER BY `test1` ASC, `test2` DESC LIMIT 200", + "SELECT COUNT(*) FROM `test` WHERE ((NOT (`test1` IS NULL)) AND (COALESCE(test2, '') != COALESCE(null, ''))) AND (test1 >= 2) ORDER BY `test1` ASC, `test2` DESC", + "SELECT * FROM `test` WHERE ((NOT (`test1` IS NULL)) AND (COALESCE(test2, '') != COALESCE(null, ''))) AND (test1 >= 2) ORDER BY `test1` ASC, `test2` DESC LIMIT 200", }, }, // valid sort and filter fields (zero results)