Skip to content

Commit e681856

Browse files
authored
ignore wildCardMinDistance when amount of nodes is 1 (#297)
1 parent a088cee commit e681856

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

finder/index.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ func (idx *IndexFinder) validatePlainQuery(query string, wildcardMinDistance int
162162

163163
var maxDist = where.MaxWildcardDistance(query)
164164

165-
if maxDist != -1 && maxDist < wildcardMinDistance {
165+
// If the amount of nodes in a plain query is equal to 1,
166+
// then make an exception
167+
// This allows to check which root nodes exist
168+
moreThanOneNode := strings.Count(query, ".") >= 1
169+
170+
if maxDist != -1 && maxDist < wildcardMinDistance && moreThanOneNode {
166171
return errs.NewErrorWithCode("query has wildcards way too early at the start and at the end of it", http.StatusBadRequest)
167172
}
168173

tests/wildcard_min_distance/test.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,12 @@ timeout = "1h"
189189
targets = [
190190
"*.*",
191191
]
192-
error_regexp = "^400: query has wildcards way too early at the start and at the end of it"
192+
error_regexp = "^400: query has wildcards way too early at the start and at the end of it"
193+
194+
[[test.render_checks]]
195+
from = "rnow-10"
196+
until = "rnow+1"
197+
timeout = "1h"
198+
targets = [
199+
"*",
200+
]

0 commit comments

Comments
 (0)