Exercise 3: One Real Win, One Real Cost — Possible Solution ==================================================================== A REAL WIN — CHAPTER 3's upsert() FIX ------------------------------ The sibling course's own barcode-cache write is a plain INSERT run only after a check finds no existing row. If two requests for the same never-before-cached barcode arrive close enough together, both can pass that check before either has written anything, and the second INSERT then fails outright by colliding with the barcode primary key. This course's upsert() - create the row if it's missing, otherwise update it - doesn't have that failure mode: the second request's own upsert() for the same barcode simply updates the row the first request just created. This counts as a genuine win specifically because it closes a real correctness gap in the sibling's own design, not because it's simply a different way of writing the same successful behavior. A REAL COST — CHAPTER 7's CASE-SENSITIVITY REGRESSION ------------------------------ The sibling course's raw SQL LIKE '%'||?||'%' is case-insensitive for ASCII automatically, with nothing extra required. This course's equivalent contains filter defaults to case-sensitive matching on SQLite, and Prisma's own mode: "insensitive" option - which fixes this cleanly on other databases - isn't supported on SQLite at all. Fixing it required generating a migration without applying it, hand-editing the SQL to add COLLATE NOCASE via SQLite's own table-recreation pattern, and only then applying it. This counts as a genuine cost specifically because the naive, seemingly-faithful Prisma translation of the sibling's own working feature quietly stopped working, not because Prisma's approach is merely more verbose or different in style. WHY THIS WORKS AS AN ANSWER ------------------------------ For both the win and the cost, it identifies a real, functional difference in behavior (a race condition actually closed; a working feature that actually broke) rather than a cosmetic or stylistic difference, matching the scorecard's own standard for what counts as each category.