From cbb12c85ce3196fa512c9a7bcc2cec0497408c85 Mon Sep 17 00:00:00 2001 From: Artyom Antonov Date: Wed, 18 Dec 2024 00:01:24 +0500 Subject: [PATCH] ignore wildCardMinDistance when amount of nodes is 1 --- finder/index.go | 7 ++++++- tests/wildcard_min_distance/test.toml | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/finder/index.go b/finder/index.go index d187e9ac..b7ac19ac 100644 --- a/finder/index.go +++ b/finder/index.go @@ -162,7 +162,12 @@ func (idx *IndexFinder) validatePlainQuery(query string, wildcardMinDistance int var maxDist = where.MaxWildcardDistance(query) - if maxDist != -1 && maxDist < wildcardMinDistance { + // If the amount of nodes in a plain query is equal to 1, + // then make an exception + // This allows to check which root nodes exist + moreThanOneNode := strings.Count(query, ".") >= 1 + + if maxDist != -1 && maxDist < wildcardMinDistance && moreThanOneNode { return errs.NewErrorWithCode("query has wildcards way too early at the start and at the end of it", http.StatusBadRequest) } diff --git a/tests/wildcard_min_distance/test.toml b/tests/wildcard_min_distance/test.toml index a5ebd003..1c3d83c0 100644 --- a/tests/wildcard_min_distance/test.toml +++ b/tests/wildcard_min_distance/test.toml @@ -189,4 +189,12 @@ timeout = "1h" targets = [ "*.*", ] -error_regexp = "^400: query has wildcards way too early at the start and at the end of it" \ No newline at end of file +error_regexp = "^400: query has wildcards way too early at the start and at the end of it" + +[[test.render_checks]] +from = "rnow-10" +until = "rnow+1" +timeout = "1h" +targets = [ + "*", +] \ No newline at end of file