4 ms·
What you picked are the happy paths. Here's the common scenario: deals = sql("select * from current_deals ..."); // Show the user the deals. // User tak
by ww520 3y ago
What you picked are the happy paths.
Here's the common scenario:
deals = sql("select * from current_deals ...");
// Show the user the deals.
// User takes his sweet time to ponder over the deals.
// Meanwhile, the deals are gone.
order = new_order()
order.deal_id = deals[5].id
order.insert()
// User calls in to complain never receiving the deal.
// Ok, need to verify the deal still exists.
sql("select deal from current_deals where id = ? for update", deals[5].id)
... insert ...
sql("commit")
That's second select..for update is referential checking in code.