Fix order search so support staff can find orders regardless of capitalization. Searches such as JOHN now return John Smith’s orders.
Ticket / Assignment
Ticket: Not provided.
Assignment: Assignment 1 — order search.
What changed
Updated apps/api/src/orders/order-repository.ts to apply LOWER() to both arguments of each instr() condition for order number, customer name, and email.
Added four tests in apps/api/src/orders/order-search-assignment-1.test.ts covering mixed-case name-only matching, uppercase email, lowercase order number, and no results.
How to test
bun run test — 15 passed, full suite after adding the four tests.
bun run build:web — passed.
git diff --check — passed.
bun run check — last reported result failed with TS2322 at order-search-assignment-1.test.ts:28: string | undefined assigned to string. Web typecheck did not run.
Manual checks:
Search for JOHN, JoHn SmItH, and JOHN.SMITH@EXAMPLE.COM; confirm ORD-1001 and ORD-1003 appear.
Search for ord-1001; confirm only ORD-1001 appears.
Search for no-matching-order; confirm no results. Clear search and confirm the list returns.
Screenshots or recordings
N/A — no visual UI changes.
Risks / follow-ups
Fix the existing test helper’s potentially undefined return value, then rerun bun run check.
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
Fix order search so support staff can find orders regardless of capitalization. Searches such as JOHN now return John Smith’s orders.
## Ticket / Assignment
- Ticket: Not provided.
- Assignment: Assignment 1 — order search.
## What changed
- Updated `apps/api/src/orders/order-repository.ts` to apply LOWER() to both arguments of each instr() condition for order number, customer name, and email.
- Added four tests in `apps/api/src/orders/order-search-assignment-1.test.ts` covering mixed-case name-only matching, uppercase email, lowercase order number, and no results.
## How to test
- bun run test — 15 passed, full suite after adding the four tests.
- bun run build:web — passed.
- git diff --check — passed.
- bun run check — last reported result failed with TS2322 at order-search-assignment-1.test.ts:28: string | undefined assigned to string. Web typecheck did not run.
Manual checks:
- Search for JOHN, JoHn SmItH, and JOHN.SMITH@EXAMPLE.COM; confirm ORD-1001 and ORD-1003 appear.
- Search for ord-1001; confirm only ORD-1001 appears.
- Search for no-matching-order; confirm no results. Clear search and confirm the list returns.
## Screenshots or recordings
N/A — no visual UI changes.
## Risks / follow-ups
- Fix the existing test helper’s potentially undefined return value, then rerun bun run check.
## 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
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
Fix order search so support staff can find orders regardless of capitalization. Searches such as JOHN now return John Smith’s orders.
Ticket / Assignment
What changed
apps/api/src/orders/order-repository.tsto apply LOWER() to both arguments of each instr() condition for order number, customer name, and email.apps/api/src/orders/order-search-assignment-1.test.tscovering mixed-case name-only matching, uppercase email, lowercase order number, and no results.How to test
Manual checks:
Screenshots or recordings
N/A — no visual UI changes.
Risks / follow-ups
PR checklist
@@ -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`,Probably better to use
lower()on thesearchabove, instead of casting it 3x here.Description is short and good, "How to test" section is not correct. 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.