From 83e2cd972d12979232eb8c1043ad3d649d03880d Mon Sep 17 00:00:00 2001 From: JP Appel Date: Mon, 28 Jul 2025 16:53:35 -0400 Subject: Fix incorrect compiling of regex queries on set categories --- pkg/query/compiler.go | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'pkg') diff --git a/pkg/query/compiler.go b/pkg/query/compiler.go index 7000544..0637fea 100644 --- a/pkg/query/compiler.go +++ b/pkg/query/compiler.go @@ -107,7 +107,31 @@ func (s Statements) buildCompile(b *strings.Builder, delim string) ([]any, error } } - if cat.IsSet() && op != OP_AP { + if op == OP_RE { + idx := 0 + for _, stmt := range opStmts { + b.WriteString("( ") + b.WriteString(catStr) + b.WriteString("IS NOT NULL AND ") + if stmt.Negated { + b.WriteString("NOT ") + } + b.WriteString(catStr) + b.WriteString(opStr) + arg, ok := stmt.Value.buildCompile(b) + b.WriteString(" )") + if ok { + args = append(args, arg) + } + b.WriteByte(' ') + if idx != len(opStmts)-1 { + b.WriteString(delim) + b.WriteByte(' ') + } + idx++ + sCount++ + } + } else if cat.IsSet() && op != OP_AP { b.WriteString(catStr) b.WriteString(opStr) b.WriteByte('(') @@ -166,30 +190,6 @@ func (s Statements) buildCompile(b *strings.Builder, delim string) ([]any, error idx++ sCount++ } - } else if op == OP_RE { - idx := 0 - for _, stmt := range opStmts { - b.WriteString("( ") - b.WriteString(catStr) - b.WriteString("IS NOT NULL AND ") - if stmt.Negated { - b.WriteString("NOT ") - } - b.WriteString(catStr) - b.WriteString(opStr) - arg, ok := stmt.Value.buildCompile(b) - b.WriteString(" )") - if ok { - args = append(args, arg) - } - b.WriteByte(' ') - if idx != len(opStmts)-1 { - b.WriteString(delim) - b.WriteByte(' ') - } - idx++ - sCount++ - } } else { idx := 0 for _, stmt := range opStmts { -- cgit v1.2.3