mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
Update to crystal-db ~> 0.4.1
Replace driver_spec for db/spec. Fix read(T?) for T = Int32, Flaot32, Time, Bool.. Fixes #19
This commit is contained in:
parent
b66dd5c337
commit
5eb85a98c6
4 changed files with 139 additions and 278 deletions
|
@ -51,18 +51,34 @@ class SQLite3::ResultSet < DB::ResultSet
|
|||
read(Int64).to_i32
|
||||
end
|
||||
|
||||
def read(type : Int32?.class) : Int32?
|
||||
read(Int64?).try &.to_i32
|
||||
end
|
||||
|
||||
def read(t : Float32.class) : Float32
|
||||
read(Float64).to_f32
|
||||
end
|
||||
|
||||
def read(type : Float32?.class) : Float32?
|
||||
read(Float64?).try &.to_f32
|
||||
end
|
||||
|
||||
def read(t : Time.class) : Time
|
||||
Time.parse read(String), SQLite3::DATE_FORMAT
|
||||
end
|
||||
|
||||
def read(t : Time?.class) : Time?
|
||||
read(String?).try { |v| Time.parse(v, SQLite3::DATE_FORMAT) }
|
||||
end
|
||||
|
||||
def read(t : Bool.class) : Bool
|
||||
read(Int64) != 0
|
||||
end
|
||||
|
||||
def read(t : Bool?.class) : Bool?
|
||||
read(Int64?).try &.!=(0)
|
||||
end
|
||||
|
||||
def column_count
|
||||
LibSQLite3.column_count(self)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue