Hotfix: gerbil search contains operator — drop trailing '*' (Gridify =* is contains; name=*a not name=*a*) + e2e mock mirrors real Gridify

This commit is contained in:
2026-06-06 08:52:02 +02:00
parent 0cee3e2710
commit 459c66bc3e
2 changed files with 9 additions and 3 deletions

View File

@@ -27,7 +27,10 @@ function matchesFilter(row: Row, filter: string | null): boolean {
if (!filter) return true if (!filter) return true
return filter.split(',').every((andPart) => return filter.split(',').every((andPart) =>
andPart.split('|').some((cond) => { andPart.split('|').some((cond) => {
let m = cond.match(/^(\w+)=\*(.*)\*(\/i)?$/) // Gridify "contains": `field=*value` — value runs to the end (optionally /i).
// Mirror the REAL backend: no trailing `*` (the old `=\*(.*)\*` regex hid the
// SQL-LIKE `name=*a*` bug that returned 0 rows against real Gridify).
let m = cond.match(/^(\w+)=\*(.*?)(\/i)?$/)
if (m) { if (m) {
return String(row[m[1]] ?? '') return String(row[m[1]] ?? '')
.toLowerCase() .toLowerCase()

View File

@@ -43,9 +43,12 @@ export interface FilterCondition {
export function condition(c: FilterCondition): string { export function condition(c: FilterCondition): string {
const escaped = escapeGridifyValue(String(c.value)) const escaped = escapeGridifyValue(String(c.value))
if (c.op === 'contains') { if (c.op === 'contains') {
// Gridify "contains" operator is =* ; default to case-insensitive. // Gridify's "contains" operator is `=*` — the value follows directly and is
// matched as a substring. Do NOT wrap the value in asterisks (SQL-LIKE habit):
// a trailing `*` is a literal character to Gridify, so `name=*a*` searches for
// the literal "a*" and matches nothing. Correct form: `name=*a`.
const suffix = c.caseInsensitive === false ? '' : '/i' const suffix = c.caseInsensitive === false ? '' : '/i'
return `${c.field}=*${escaped}*${suffix}` return `${c.field}=*${escaped}${suffix}`
} }
// Gridify's equals operator is a single '='; callers use '==' semantically. // Gridify's equals operator is a single '='; callers use '==' semantically.
const op = c.op === '==' ? '=' : c.op const op = c.op === '==' ? '=' : c.op