Staff searching orders by pasting a customer name in uppercase (e.g. JOHN) got no results, even though a matching order (customer "John Smith") existed. This caused friction when copying customer details from other systems into the search box.
Ticket / Assignment
Ticket: Support-reported inconsistent order search behavior (case sensitivity)
Assignment: Assignment 1
What changed
apps/api/src/orders/order-repository.ts: wrapped both operands of each instr() check (order number, customer name, customer email) in lower(), so the search filter in listOrderSummaries matches regardless of letter case.
No route, schema, or frontend changes were needed — the bug was isolated to the repository-layer search filter, consistent with CONTRIBUTING.md's "business rules stay in the repository layer" convention.
How to test
bun run check # fails only on a pre-existing, unrelated TS error in order-search-assignment-1.test.ts (line 28); reproduces identically on master before this change
bun run test# 11 pass, 0 fail
bun run build:web
Manual checks:
Searched /api/orders?query=JOHN and confirmed ORD-1001 and ORD-1003 (customer John Smith) are returned.
Confirmed the pre-existing test order-search-assignment-1.test.ts ("searches orders case-insensitively by customer name") passes, where it previously failed.
Screenshots or recordings
N/A (backend-only change)
Risks / follow-ups
lower() in SQLite only folds ASCII case by default; non-ASCII customer names (e.g. accented characters) won't case-fold. Not in scope for this ticket — flagging as a possible follow-up if support sees it.
bun run check has a pre-existing TypeScript error in order-search-assignment-1.test.ts (unrelated to this change, reproduces on master) — left untouched to keep this PR scoped to the search bug.
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
known risks or follow-ups are called out
## Summary
Staff searching orders by pasting a customer name in uppercase (e.g. `JOHN`) got no results, even though a matching order (customer "John Smith") existed. This caused friction when copying customer details from other systems into the search box.
## Ticket / Assignment
- Ticket: Support-reported inconsistent order search behavior (case sensitivity)
- Assignment: Assignment 1
## What changed
- `apps/api/src/orders/order-repository.ts`: wrapped both operands of each `instr()` check (order number, customer name, customer email) in `lower()`, so the search filter in `listOrderSummaries` matches regardless of letter case.
- No route, schema, or frontend changes were needed — the bug was isolated to the repository-layer search filter, consistent with CONTRIBUTING.md's "business rules stay in the repository layer" convention.
## How to test
```bash
bun run check # fails only on a pre-existing, unrelated TS error in order-search-assignment-1.test.ts (line 28); reproduces identically on master before this change
bun run test # 11 pass, 0 fail
bun run build:web
```
Manual checks:
- Searched `/api/orders?query=JOHN` and confirmed `ORD-1001` and `ORD-1003` (customer John Smith) are returned.
- Confirmed the pre-existing test `order-search-assignment-1.test.ts` ("searches orders case-insensitively by customer name") passes, where it previously failed.
## Screenshots or recordings
N/A (backend-only change)
## Risks / follow-ups
- `lower()` in SQLite only folds ASCII case by default; non-ASCII customer names (e.g. accented characters) won't case-fold. Not in scope for this ticket — flagging as a possible follow-up if support sees it.
- `bun run check` has a pre-existing TypeScript error in `order-search-assignment-1.test.ts` (unrelated to this change, reproduces on master) — left untouched to keep this PR scoped to the search bug.
## 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
- [x] known risks or follow-ups are called out
instr() in SQLite compares bytes, so searching for a customer name
in uppercase (e.g. "JOHN") silently missed lowercase-stored matches
like "John". Lowercase both sides of the order number, name, and
email comparisons so search matches regardless of the case staff
paste in.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary needs to be about the PR, not the ticket. Can just link the ticket next time in ticket/assignment section. Otherwise, good job on getting the assignment test to pass.
Summary needs to be about the PR, not the ticket. Can just link the ticket next time in ticket/assignment section. Otherwise, good job on getting the assignment test to pass.
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
Staff searching orders by pasting a customer name in uppercase (e.g.
JOHN) got no results, even though a matching order (customer "John Smith") existed. This caused friction when copying customer details from other systems into the search box.Ticket / Assignment
What changed
apps/api/src/orders/order-repository.ts: wrapped both operands of eachinstr()check (order number, customer name, customer email) inlower(), so the search filter inlistOrderSummariesmatches regardless of letter case.How to test
Manual checks:
/api/orders?query=JOHNand confirmedORD-1001andORD-1003(customer John Smith) are returned.order-search-assignment-1.test.ts("searches orders case-insensitively by customer name") passes, where it previously failed.Screenshots or recordings
N/A (backend-only change)
Risks / follow-ups
lower()in SQLite only folds ASCII case by default; non-ASCII customer names (e.g. accented characters) won't case-fold. Not in scope for this ticket — flagging as a possible follow-up if support sees it.bun run checkhas a pre-existing TypeScript error inorder-search-assignment-1.test.ts(unrelated to this change, reproduces on master) — left untouched to keep this PR scoped to the search bug.PR checklist
CONTRIBUTING.md@@ -42,3 +42,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`,Should move the
lower()to thesearchabove, to avoid casting it 3x here.Summary needs to be about the PR, not the ticket. Can just link the ticket next time in ticket/assignment section. Otherwise, good job on getting the assignment test to pass.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.