question 396 Software Architecture · medium
Fix the adapter that leaks database rows
The pricing core works with product dictionaries (product["price"]). Its SQLite adapter returns raw database rows, which are tuples, so the core crashes with TypeError: tuple indices must be integers. Fix the adapter (the core must not learn about SQL rows): get returns a dictionary with sku, name and price, or None for an unknown SKU.
Class
SqliteProducts(connection) with get(sku)Returns
{"sku": ..., "name": ..., "price": ...} or NoneCore
price_with_tax(store, sku, rate) (given) must stay unchanged