Skip to content

fix(items): search material properties across all displayed columns - #1262

Merged
aashu0148 merged 5 commits into
mainfrom
fix/material-properties-search-all-columns
Aug 5, 2026
Merged

fix(items): search material properties across all displayed columns#1262
aashu0148 merged 5 commits into
mainfrom
fix/material-properties-search-all-columns

Conversation

@sidgaikwad

@sidgaikwad sidgaikwad commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

The free-text search on the Material Properties lists — Types, Dimensions, Finishes, and Grades — only matched the name column. 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:

List Searchable columns
Types name (Type), substanceName (Substance), formName (Shape), id (ID)
Dimensions name (Dimension), formName (Shape), id (ID)
Finishes name (Finish), substanceName (Substance), id (ID)
Grades 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

  • All four service functions in apps/erp/app/modules/items/items.service.ts swap the single .ilike("name", …) for a multi-column query.or("name.ilike.…,…").
  • The company-scoping .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.
  • Follows the existing multi-column search pattern already used across the codebase (e.g. 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

    • Improved search for material dimensions, finishes, grades, and types.
    • Searches now match identifiers and related labels across multiple fields, making results easier to find using different descriptive terms.
    • Special characters in search queries are handled more safely, reducing unexpected or incomplete results.
  • Improvements

    • Enhanced search consistency across material detail views for more reliable results.

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
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
academy Ready Ready Preview Aug 4, 2026 8:31pm
carbon Ready Ready Preview Aug 4, 2026 8:31pm
docs Ready Ready Preview Aug 4, 2026 8:31pm
mes Ready Ready Preview Aug 4, 2026 8:31pm

Request Review

@github-actions github-actions Bot added erp complexity: low Low-complexity PR labels Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 18f4cc6c-95d8-4b4c-b6c5-4d5c401f2fdb

📥 Commits

Reviewing files that changed from the base of the PR and between a8de5e5 and 36750d5.

📒 Files selected for processing (1)
  • apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json

📝 Walkthrough

Walkthrough

Material 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.

Changes

Material search filtering

Layer / File(s) Summary
Expand material search fields
apps/erp/app/modules/items/items.service.ts
A shared helper builds escaped OR-based ilike filters. Dimensions, finishes, grades, and types search names, related labels, and IDs.

Tool metadata refresh

Layer / File(s) Summary
Update generated timestamp
apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
The metadata generated timestamp is updated.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • crbnos/carbon#1238: Both changes improve multi-column search filtering in items.service.ts.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: searching material properties across all displayed columns.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/material-properties-search-all-columns

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc7865a and a6f880d.

📒 Files selected for processing (2)
  • apps/erp/app/modules/items/items.service.ts
  • apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json

Comment thread apps/erp/app/modules/items/items.service.ts
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.
@aashu0148
aashu0148 merged commit d036f32 into main Aug 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

checks: passing CI checks passed complexity: low Low-complexity PR erp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants