jeremyevans/sequel — pull request #822 by jkakar (2014-05-27 21:13:24+00:00)
Title: there-can-be-only-one

- Add a new `Dataset.one!` action that returns a single row, if
available, or `nil` if no match is found. If more than one row
matches the conditions a `TooManyRows` exception is raised.

Perhaps this already exists somewhere in Sequel, but I've not found
it, so I decided to take a stab at implementing it. I'm not very
happy with the tests, and could use some advice about how to do better
there (specially, making sure a record is correctly returned when one
row does exist).

This is modeled after the `ResultSet.one` method in Storm:

http://people.canonical.com/~therve/storm/storm.store.ResultSet.html#one