mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Deal with unexpected ResultSet#read types during runtime.
This commit is contained in:
parent
545d758ae0
commit
bb3203301b
2 changed files with 8 additions and 3 deletions
|
@ -76,7 +76,12 @@ module DB
|
|||
|
||||
# Reads the next column value as a **type**
|
||||
def read(type : T.class) : T forall T
|
||||
read.as(T)
|
||||
value = read
|
||||
if value.is_a?(T)
|
||||
value
|
||||
else
|
||||
raise "#{self.class}#read returned a #{value.class}. A #{T} was expected."
|
||||
end
|
||||
end
|
||||
|
||||
# Reads the next columns and returns a tuple of the values.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue