Support reported that order search missed matches when the typed case differed from stored data (e.g. "JOHN" returned nothing, though John Smith has two orders). Search now ignores letter case for order number, customer name, and email, so staff find the same orders whatever case they type.
Ticket / Assignment
Ticket: Inconsistent order search behavior with uppercase input
Assignment:
What changed
apps/api/src/orders/order-repository.ts: listOrderSummaries compares lower(column) with lower(search) in its existing instr() checks. Root cause: SQLite instr() is case-sensitive. instr is kept (not LIKE) so % and _ in search text stay literal.
apps/api/src/orders/orders-routes.test.ts: two API regression tests — customer name searched as JOHN SMITH (matches only through the name column) and order number searched as ord-1001.
How to test
bun run check
bun run test
Both new tests failed before the fix (returned []) and pass after it; order-routes file 8/8, full suite 12/12, typecheck clean.
Mutation check: removing lower() from the name comparison alone makes the customer-name test fail, confirming it pins the name column.
bun run build:web was not run: no web code changed, and its Tailwind step rewrites app.css.
Manual checks:
GET /api/orders?query=JOHN, john, John each returned ORD-1001 and ORD-1003
GET /api/orders?query=ord-1003 returned ORD-1003; no query returned all 7 orders
Browser pass on the Order page has done
Screenshots or recordings
N/A (no UI change)
Risks / follow-ups
SQLite's built-in lower() only folds ASCII, so accented names (É vs é) still match case-sensitively. Follow-up if non-ASCII customer data matters.
Search still scans the table (unchanged; instr could not use an index before either).
Unrelated tooling note: root bun run seed:user waits on an interactive prompt; running it from apps/api with an employee argument works.
PR checklist
change is scoped to one ticket or one small reviewable concern
acceptance criteria were checked
code follows CONTRIBUTING.md
no unrelated refactor is mixed in
debug code and temporary logs are removed
relevant automated checks were run locally
changed behavior was manually tested when needed (over HTTP; browser pass pending)
known risks or follow-ups are called out
## Summary
Support reported that order search missed matches when the typed case differed from stored data (e.g. "JOHN" returned nothing, though John Smith has two orders). Search now ignores letter case for order number, customer name, and email, so staff find the same orders whatever case they type.
## Ticket / Assignment
- Ticket: Inconsistent order search behavior with uppercase input
- Assignment:
## What changed
- `apps/api/src/orders/order-repository.ts`: `listOrderSummaries` compares `lower(column)` with `lower(search)` in its existing `instr()` checks. Root cause: SQLite `instr()` is case-sensitive. `instr` is kept (not `LIKE`) so `%` and `_` in search text stay literal.
- `apps/api/src/orders/orders-routes.test.ts`: two API regression tests — customer name searched as `JOHN SMITH` (matches only through the name column) and order number searched as `ord-1001`.
## How to test
```bash
bun run check
bun run test
```
- Both new tests failed before the fix (returned `[]`) and pass after it; order-routes file 8/8, full suite 12/12, typecheck clean.
- Mutation check: removing `lower()` from the name comparison alone makes the customer-name test fail, confirming it pins the name column.
- `bun run build:web` was not run: no web code changed, and its Tailwind step rewrites `app.css`.
Manual checks:
- `GET /api/orders?query=JOHN`, `john`, `John` each returned ORD-1001 and ORD-1003
- `GET /api/orders?query=ord-1003` returned ORD-1003; no query returned all 7 orders
- Browser pass on the Order page has done
## Screenshots or recordings
`N/A (no UI change)`
## Risks / follow-ups
- SQLite's built-in `lower()` only folds ASCII, so accented names (É vs é) still match case-sensitively. Follow-up if non-ASCII customer data matters.
- Search still scans the table (unchanged; `instr` could not use an index before either).
- Unrelated tooling note: root `bun run seed:user` waits on an interactive prompt; running it from `apps/api` with an `employee` argument works.
## PR checklist
- [x] change is scoped to one ticket or one small reviewable concern
- [x] acceptance criteria were checked
- [x] code follows `CONTRIBUTING.md`
- [x] no unrelated refactor is mixed in
- [x] debug code and temporary logs are removed
- [x] relevant automated checks were run locally
- [x] changed behavior was manually tested when needed (over HTTP; browser pass pending)
- [x] known risks or follow-ups are called out
Searching "JOHN" or "ord-1001" returned no orders because SQLite instr()
is case-sensitive. Compare lowercased values for order number, customer
name, and email. Adds API regression tests for both cases.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HUfxyr6EcRi4EYSX1wLoRh
Search "JOHN SMITH" instead of "JOHN" so the regression test only matches
through the customer name column ("john" alone also matched the email),
ensuring case-insensitive name matching is verified on its own.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HUfxyr6EcRi4EYSX1wLoRh
cq0622
requested review from derrick 2026-09-11 06:45:39 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Support reported that order search missed matches when the typed case differed from stored data (e.g. "JOHN" returned nothing, though John Smith has two orders). Search now ignores letter case for order number, customer name, and email, so staff find the same orders whatever case they type.
Ticket / Assignment
What changed
apps/api/src/orders/order-repository.ts:listOrderSummariescompareslower(column)withlower(search)in its existinginstr()checks. Root cause: SQLiteinstr()is case-sensitive.instris kept (notLIKE) so%and_in search text stay literal.apps/api/src/orders/orders-routes.test.ts: two API regression tests — customer name searched asJOHN SMITH(matches only through the name column) and order number searched asord-1001.How to test
[]) and pass after it; order-routes file 8/8, full suite 12/12, typecheck clean.lower()from the name comparison alone makes the customer-name test fail, confirming it pins the name column.bun run build:webwas not run: no web code changed, and its Tailwind step rewritesapp.css.Manual checks:
GET /api/orders?query=JOHN,john,Johneach returned ORD-1001 and ORD-1003GET /api/orders?query=ord-1003returned ORD-1003; no query returned all 7 ordersScreenshots or recordings
N/A (no UI change)Risks / follow-ups
lower()only folds ASCII, so accented names (É vs é) still match case-sensitively. Follow-up if non-ASCII customer data matters.instrcould not use an index before either).bun run seed:userwaits on an interactive prompt; running it fromapps/apiwith anemployeeargument works.PR checklist
CONTRIBUTING.mdSearch "JOHN SMITH" instead of "JOHN" so the regression test only matches through the customer name column ("john" alone also matched the email), ensuring case-insensitive name matching is verified on its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HUfxyr6EcRi4EYSX1wLoRh@@ -42,3 +44,1 @@sql`instr(${orders.orderNumber}, ${search}) > 0`,sql`instr(${users.name}, ${search}) > 0`,sql`instr(${users.email}, ${search}) > 0`sql`instr(lower(${orders.orderNumber}), lower(${search})) > 0`,Probably better to move the lower() function to the
searchabove, instead of casting lower 3x here.PR Description and contents a little verbose, but otherwise a good job at getting the assignment test to pass.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.