6 karma · joined Jun 20, 2015 (11y ago) · 2 submissions
comment 6y ago · link · parent
Book.joins(:author).where(author: { deceased: true }).map &:isbn`
> first class transactions / decrement race condition Book.find(isbn: 1).decrement :copies_in_stock
> Row-locking Book.transaction do
b = Book.lock("FOR UPDATE NOWAIT").find_(1)
# logic around handling out of stock
b.copies_in_stock -= 1
b.save!
end
Those are all of your examples and the Ruby code that implements the solution you want. (Disclaimer: there are probably small syntax errors here, you get the gist)Honestly this article sounds like it was written by someone who read a 10 year old Martin Fowler article and decided to critique it without even a cursory understanding of modern ORMs. Even more strangely, when everyone starts pointing out the obvious fact that ORMs do solve these problems in practice, you've decided to move the goalposts to say "oh, well the straw man abstract pattern doesn't solve for these real-world problems."
In the future I'd recommend you familiarize yourself with a problem space before trying to publish on it.
comment 6y ago · link · parent
This is a bit like acting as if you're the first person to realize that null pointer deferences are a problem and happily telling the entire world to "just switch to pass by value."