mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Add NoResultsError (#121)
This commit is contained in:
parent
f128d6ddf3
commit
f08a4da60a
3 changed files with 14 additions and 1 deletions
|
@ -208,4 +208,13 @@ describe DB::Statement do
|
|||
db.pool.is_available?(DummyDriver::DummyConnection.connections.first)
|
||||
end
|
||||
end
|
||||
|
||||
it "raises NoResultsError for scalar" do
|
||||
with_dummy_connection do |cnn|
|
||||
stmt = cnn.prepared ""
|
||||
expect_raises DB::NoResultsError do
|
||||
stmt.scalar "SELECT LIMIT 0"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,4 +29,8 @@ module DB
|
|||
|
||||
class Rollback < Error
|
||||
end
|
||||
|
||||
# Raised when a scalar query returns no results.
|
||||
class NoResultsError < Error
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module DB
|
|||
end
|
||||
end
|
||||
|
||||
raise "no results"
|
||||
raise NoResultsError.new("no results")
|
||||
end
|
||||
|
||||
# See `QueryMethods#query`
|
||||
|
|
Loading…
Reference in a new issue