diff --git a/find/handler_test.go b/find/handler_test.go index 128c9796b..e25dc4454 100644 --- a/find/handler_test.go +++ b/find/handler_test.go @@ -62,4 +62,9 @@ func TestFind(t *testing.T) { "host.top.cpu.cpu%2A", "SELECT Path FROM graphite_tree WHERE (Level = 4) AND (Path LIKE 'host.top.cpu.cpu%') GROUP BY Path HAVING argMax(Deleted, Version)==0", ) + + testCase( + "host.?cpu", + "SELECT Path FROM graphite_tree WHERE (Level = 2) AND (Path LIKE 'host.%') AND (match(Path, '^host[.][^.]cpu[.]?$')) GROUP BY Path HAVING argMax(Deleted, Version)==0", + ) } diff --git a/finder/base.go b/finder/base.go index a4aad1649..42c41d9dc 100644 --- a/finder/base.go +++ b/finder/base.go @@ -43,7 +43,7 @@ func (b *BaseFinder) where(query string) string { } // before any wildcard symbol - simplePrefix := query[:strings.IndexAny(query, "[]{}*")] + simplePrefix := query[:strings.IndexAny(query, "[]{}*?")] if len(simplePrefix) > 0 { w.Andf("Path LIKE %s", Q(simplePrefix+`%`))