Exercise 1: The Bug Class Avoided by a Typed Date Column — Possible Solution ==================================================================== WHAT THE EXPRESS SIBLING HAD TO WARN ABOUT ------------------------------ SQLite has no dedicated date type in Food Tracker (React + Express)'s own raw-SQL setup, so expiry_date was stored as plain TEXT. Comparing two TEXT values with <= compares them character by character (lexicographically), not according to real calendar logic - this only produced correct results because every date happened to be consistently stored as YYYY-MM-DD, a format where lexicographic order and chronological order happen to agree. That course had to warn explicitly that a single date stored in a different format would silently break every comparison, with no error at all. WHY THIS COURSE DOESN'T HAVE THE SAME PROBLEM ------------------------------ Chapter 2 declared expiry_date as a real SQLAlchemy Date column, not a plain string field. Comparing models.Item.expiry_date <= threshold compares genuine date values using real chronological logic, regardless of how the underlying database driver happens to represent dates internally - there's no possibility of a format inconsistency silently breaking the comparison, because the comparison was never based on string formatting in the first place. WHY THIS TRACES BACK TO CHAPTER 2 ------------------------------ This isn't something the alerts route itself had to specifically guard against - it's a structural consequence of a decision already made two chapters earlier, when expiry_date was modeled as a typed column rather than a raw string. The bug class was avoided before this chapter's own route was ever written. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly identifies the specific bug (lexicographic vs. chronological comparison on TEXT-stored dates) that the Express sibling had to name, correctly explains why a typed Date column avoids it structurally, and correctly traces the real cause back to Chapter 2's own modeling decision rather than anything specific to this route.