This commit is contained in:
Aliaksandr Valialkin 2024-05-22 18:39:53 +02:00
parent dbbab6c78e
commit 1e2f5e7294
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 4 additions and 6 deletions

View file

@ -1016,9 +1016,6 @@ func parseFilterRegexp(lex *lexer, fieldName string) (filter, error) {
}
func parseFilterGT(lex *lexer, fieldName string) (filter, error) {
if fieldName == "" {
return nil, fmt.Errorf("'>' and '>=' must be prefixed with the field name")
}
lex.nextToken()
includeMinValue := false
@ -1048,9 +1045,6 @@ func parseFilterGT(lex *lexer, fieldName string) (filter, error) {
}
func parseFilterLT(lex *lexer, fieldName string) (filter, error) {
if fieldName == "" {
return nil, fmt.Errorf("'<' and '<=' must be prefixed with the field name")
}
lex.nextToken()
includeMaxValue := false

View file

@ -505,6 +505,8 @@ func TestParseRangeFilter(t *testing.T) {
f(`duration:range[100ns, 1y2w2.5m3s5ms]`, `duration`, 100, 1*nsecsPerYear+2*nsecsPerWeek+2.5*nsecsPerMinute+3*nsecsPerSecond+5*nsecsPerMillisecond)
f(`>=10`, ``, 10, inf)
f(`<=10`, ``, -inf, 10)
f(`foo:>10.43`, `foo`, nextafter(10.43, inf), inf)
f(`foo: > -10.43`, `foo`, nextafter(-10.43, inf), inf)
f(`foo:>=10.43`, `foo`, 10.43, inf)
@ -750,6 +752,8 @@ func TestParseQuerySuccess(t *testing.T) {
f(`foo: >= 10.5M`, `foo:>=10.5M`)
f(`foo: < 10.5M`, `foo:<10.5M`)
f(`foo: <= 10.5M`, `foo:<=10.5M`)
f(`foo:(>10 <=20)`, `foo:>10 foo:<=20`)
f(`>=10 <20`, `>=10 <20`)
// re filter
f("re('foo|ba(r.+)')", `re("foo|ba(r.+)")`)