mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
update Slice(UInt8) to Bytes
This commit is contained in:
parent
11e24e1c65
commit
8025ecaa13
5 changed files with 17 additions and 17 deletions
|
@ -231,14 +231,14 @@ describe DB do
|
|||
db.query "query" { }
|
||||
db.query "query", 1 { }
|
||||
db.query "query", 1, "string" { }
|
||||
db.query("query", Slice(UInt8).new(4)) { }
|
||||
db.query("query", Bytes.new(4)) { }
|
||||
db.query("query", 1, "string", FooValue.new(5)) { }
|
||||
db.query "query", [1, "string", FooValue.new(5)] { }
|
||||
|
||||
db.query("query").close
|
||||
db.query("query", 1).close
|
||||
db.query("query", 1, "string").close
|
||||
db.query("query", Slice(UInt8).new(4)).close
|
||||
db.query("query", Bytes.new(4)).close
|
||||
db.query("query", 1, "string", FooValue.new(5)).close
|
||||
db.query("query", [1, "string", FooValue.new(5)]).close
|
||||
end
|
||||
|
@ -248,14 +248,14 @@ describe DB do
|
|||
db.query "query" { }
|
||||
db.query "query", 1 { }
|
||||
db.query "query", 1, "string" { }
|
||||
db.query("query", Slice(UInt8).new(4)) { }
|
||||
db.query("query", Bytes.new(4)) { }
|
||||
db.query("query", 1, "string", BarValue.new(5)) { }
|
||||
db.query "query", [1, "string", BarValue.new(5)] { }
|
||||
|
||||
db.query("query").close
|
||||
db.query("query", 1).close
|
||||
db.query("query", 1, "string").close
|
||||
db.query("query", Slice(UInt8).new(4)).close
|
||||
db.query("query", Bytes.new(4)).close
|
||||
db.query("query", 1, "string", BarValue.new(5)).close
|
||||
db.query("query", [1, "string", BarValue.new(5)]).close
|
||||
end
|
||||
|
@ -267,7 +267,7 @@ describe DB do
|
|||
db.exec("query")
|
||||
db.exec("query", 1)
|
||||
db.exec("query", 1, "string")
|
||||
db.exec("query", Slice(UInt8).new(4))
|
||||
db.exec("query", Bytes.new(4))
|
||||
db.exec("query", 1, "string", FooValue.new(5))
|
||||
db.exec("query", [1, "string", FooValue.new(5)])
|
||||
end
|
||||
|
@ -277,7 +277,7 @@ describe DB do
|
|||
db.exec("query")
|
||||
db.exec("query", 1)
|
||||
db.exec("query", 1, "string")
|
||||
db.exec("query", Slice(UInt8).new(4))
|
||||
db.exec("query", Bytes.new(4))
|
||||
db.exec("query", 1, "string", BarValue.new(5))
|
||||
db.exec("query", [1, "string", BarValue.new(5)])
|
||||
end
|
||||
|
|
|
@ -78,7 +78,7 @@ class DummyDriver < DB::Driver
|
|||
@values : Array(String)?
|
||||
|
||||
@@last_result_set : self?
|
||||
@@next_column_type : Nil.class | String.class | Int32.class | Int64.class | Float32.class | Float64.class | Slice(UInt8).class
|
||||
@@next_column_type : Nil.class | String.class | Int32.class | Int64.class | Float32.class | Float64.class | Bytes.class
|
||||
|
||||
def initialize(statement, query)
|
||||
super(statement)
|
||||
|
@ -152,17 +152,17 @@ class DummyDriver < DB::Driver
|
|||
read?(String).try &.to_f64
|
||||
end
|
||||
|
||||
def read?(t : Slice(UInt8).class)
|
||||
def read?(t : Bytes.class)
|
||||
value = read?
|
||||
if value.is_a?(Nil)
|
||||
value
|
||||
elsif value.is_a?(String)
|
||||
ary = value.bytes
|
||||
Slice.new(ary.to_unsafe, ary.size)
|
||||
elsif value.is_a?(Slice(UInt8))
|
||||
elsif value.is_a?(Bytes)
|
||||
value
|
||||
else
|
||||
raise "#{value} is not convertible to Slice(UInt8)"
|
||||
raise "#{value} is not convertible to Bytes"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,9 +101,9 @@ describe DummyDriver do
|
|||
db.query("az,AZ") do |rs|
|
||||
rs.move_next
|
||||
ary = [97u8, 122u8]
|
||||
rs.read(Slice(UInt8)).should eq(Slice.new(ary.to_unsafe, ary.size))
|
||||
rs.read(Bytes).should eq(Bytes.new(ary.to_unsafe, ary.size))
|
||||
ary = [65u8, 90u8]
|
||||
rs.read(Slice(UInt8)).should eq(Slice.new(ary.to_unsafe, ary.size))
|
||||
rs.read(Bytes).should eq(Bytes.new(ary.to_unsafe, ary.size))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -134,9 +134,9 @@ describe DummyDriver do
|
|||
it "executes and selects blob" do
|
||||
with_dummy do |db|
|
||||
ary = UInt8[0x53, 0x51, 0x4C]
|
||||
slice = Slice.new(ary.to_unsafe, ary.size)
|
||||
slice = Bytes.new(ary.to_unsafe, ary.size)
|
||||
DummyDriver::DummyResultSet.next_column_type = typeof(slice)
|
||||
(db.scalar("?", slice) as Slice(UInt8)).to_a.should eq(ary)
|
||||
(db.scalar("?", slice).as(Bytes)).to_a.should eq(ary)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ module DB
|
|||
# Types supported to interface with database driver.
|
||||
# These can be used in any `ResultSet#read` or any `Database#query` related
|
||||
# method to be used as query parameters
|
||||
TYPES = [Nil, String, Int32, Int64, Float32, Float64, Slice(UInt8)]
|
||||
TYPES = [Nil, String, Int32, Int64, Float32, Float64, Bytes]
|
||||
|
||||
# See `DB::TYPES` in `DB`. `Any` is a union of all types in `DB::TYPES`
|
||||
{% begin %}
|
||||
|
|
|
@ -57,8 +57,8 @@ module DB
|
|||
return rs.read?(Float32)
|
||||
when Float64.class
|
||||
return rs.read?(Float64)
|
||||
when Slice(UInt8).class
|
||||
return rs.read?(Slice(UInt8))
|
||||
when Bytes.class
|
||||
return rs.read?(Bytes)
|
||||
when Nil.class
|
||||
return rs.read?(Int32)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue