fix(items): search material properties across all displayed columns - #1262
Conversation
The free-text search on the Types, Dimensions, Finishes, and Grades material-property lists only matched the `name` column, so searching by substance, shape, or id returned nothing. Broaden each list query to match every displayed text column of its view: - Types: name, substanceName, formName, id - Dimensions: name, formName, id - Finishes: name, substanceName, id - Grades: name, substanceName, id
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughMaterial searches now match IDs and related label fields in four material list queries. The search filter escapes backslashes and quotes. The MCP tool metadata generated timestamp is also updated. ChangesMaterial search filtering
Tool metadata refresh
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/erp/app/modules/items/items.service.ts`:
- Around line 1284-1286: Sanitize and escape args.search before interpolating it
into the PostgREST .or() filter strings at the affected query sites, preserving
one consistent escaped pattern across name, formName or other matching text
columns, and id. Ensure punctuation cannot alter filter syntax, and add
regression coverage for searches containing commas, periods, colons, wildcards,
percent signs, and quotes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: dff98a6d-fa51-49d8-9930-86a85c016aae
📒 Files selected for processing (2)
apps/erp/app/modules/items/items.service.tsapps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
Switching the Types/Dimensions/Finishes/Grades searches to a multi-column .or(...) interpolated the raw search term into PostgREST's filter grammar, where a comma separates OR-conditions and parentheses delimit groups, so a search containing punctuation (e.g. "A36, hot" or "steel (mild)") broke the filter. Centralize construction in buildSearchFilter, which wraps the term in a double-quoted PostgREST value and escapes embedded quotes and backslashes so reserved punctuation stays literal and no extra conditions can be injected; ILIKE wildcard semantics are unchanged.
Problem
The free-text search on the Material Properties lists — Types, Dimensions, Finishes, and Grades — only matched the
namecolumn. So on the Types list, searching by substance, shape, or id returned nothing; the same applied to the other three lists.Fix
Each list query now matches every displayed text column of its view, instead of only
name:name(Type),substanceName(Substance),formName(Shape),id(ID)name(Dimension),formName(Shape),id(ID)name(Finish),substanceName(Substance),id(ID)name(Grade),substanceName(Substance),id(ID)This mirrors the columns each table already shows, so search now covers exactly what the user sees. The
companyId("Standard") column is a badge, not text, so it's excluded.Implementation notes
apps/erp/app/modules/items/items.service.tsswap the single.ilike("name", …)for a multi-columnquery.or("name.ilike.…,…")..or(companyId.eq.…,companyId.is.null)and the search.or(…)are AND-combined by PostgREST, so cross-tenant scoping is preserved — you still only see your company's rows plus system-seeded (global) ones.getUnitOfMeasures, gauges, non-conformances).Video
(https://drive.google.com/file/d/18NtwZa9DoAdu3s_pvHrBYmY3g9fxkHwg/view?usp=sharing)
TODO: add walkthrough video
🤖 Generated with Claude Code
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Improvements