mirror of
https://gitea.invidious.io/iv-org/shard-crystal-sqlite3.git
synced 2024-08-15 00:53:26 +00:00
update Slice(UInt8) to Bytes
This commit is contained in:
parent
c8d5acceae
commit
d65575cd77
3 changed files with 9 additions and 9 deletions
|
@ -114,7 +114,7 @@ describe Driver do
|
||||||
|
|
||||||
it "executes and selects blob" do
|
it "executes and selects blob" do
|
||||||
with_db do |db|
|
with_db do |db|
|
||||||
slice = db.scalar(%(select X'53514C697465')).as(Slice(UInt8))
|
slice = db.scalar(%(select X'53514C697465')).as(Bytes)
|
||||||
slice.to_a.should eq([0x53, 0x51, 0x4C, 0x69, 0x74, 0x65])
|
slice.to_a.should eq([0x53, 0x51, 0x4C, 0x69, 0x74, 0x65])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -122,7 +122,7 @@ describe Driver do
|
||||||
it "executes with bind blob" do
|
it "executes with bind blob" do
|
||||||
with_db do |db|
|
with_db do |db|
|
||||||
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
||||||
slice = db.scalar(%(select cast(? as BLOB)), Slice.new(ary.to_unsafe, ary.size)).as(Slice(UInt8))
|
slice = db.scalar(%(select cast(? as BLOB)), Bytes.new(ary.to_unsafe, ary.size)).as(Bytes)
|
||||||
slice.to_a.should eq(ary)
|
slice.to_a.should eq(ary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -161,7 +161,7 @@ describe Driver do
|
||||||
rs.column_type(0).should eq(String)
|
rs.column_type(0).should eq(String)
|
||||||
rs.column_type(1).should eq(Int64)
|
rs.column_type(1).should eq(Int64)
|
||||||
rs.column_type(2).should eq(Float64)
|
rs.column_type(2).should eq(Float64)
|
||||||
rs.column_type(3).should eq(Slice(UInt8))
|
rs.column_type(3).should eq(Bytes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -193,9 +193,9 @@ describe Driver do
|
||||||
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65]
|
||||||
|
|
||||||
db.exec "create table table1 (col1 blob)"
|
db.exec "create table table1 (col1 blob)"
|
||||||
db.exec %(insert into table1 values (?)), Slice.new(ary.to_unsafe, ary.size)
|
db.exec %(insert into table1 values (?)), Bytes.new(ary.to_unsafe, ary.size)
|
||||||
|
|
||||||
slice = db.scalar("select cast(col1 as blob) from table1").as(Slice(UInt8))
|
slice = db.scalar("select cast(col1 as blob) from table1").as(Bytes)
|
||||||
slice.to_a.should eq(ary)
|
slice.to_a.should eq(ary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,13 +52,13 @@ class SQLite3::ResultSet < DB::ResultSet
|
||||||
moving_column { |col| LibSQLite3.column_double(self, col) }
|
moving_column { |col| LibSQLite3.column_double(self, col) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(t : Slice(UInt8).class) : Slice(UInt8)
|
def read(t : Bytes.class) : Bytes
|
||||||
moving_column do |col|
|
moving_column do |col|
|
||||||
blob = LibSQLite3.column_blob(self, col)
|
blob = LibSQLite3.column_blob(self, col)
|
||||||
bytes = LibSQLite3.column_bytes(self, col)
|
bytes = LibSQLite3.column_bytes(self, col)
|
||||||
ptr = Pointer(UInt8).malloc(bytes)
|
ptr = Pointer(UInt8).malloc(bytes)
|
||||||
ptr.copy_from(blob, bytes)
|
ptr.copy_from(blob, bytes)
|
||||||
Slice(UInt8).new(ptr, bytes)
|
Bytes.new(ptr, bytes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class SQLite3::ResultSet < DB::ResultSet
|
||||||
case LibSQLite3.column_type(self, index)
|
case LibSQLite3.column_type(self, index)
|
||||||
when Type::INTEGER; Int64
|
when Type::INTEGER; Int64
|
||||||
when Type::FLOAT ; Float64
|
when Type::FLOAT ; Float64
|
||||||
when Type::BLOB ; Slice(UInt8)
|
when Type::BLOB ; Bytes
|
||||||
when Type::TEXT ; String
|
when Type::TEXT ; String
|
||||||
when Type::NULL ; Nil
|
when Type::NULL ; Nil
|
||||||
else
|
else
|
||||||
|
|
|
@ -52,7 +52,7 @@ class SQLite3::Statement < DB::Statement
|
||||||
check LibSQLite3.bind_text(self, index, value, value.bytesize, nil)
|
check LibSQLite3.bind_text(self, index, value, value.bytesize, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
private def bind_arg(index, value : Slice(UInt8))
|
private def bind_arg(index, value : Bytes)
|
||||||
check LibSQLite3.bind_blob(self, index, value, value.size, nil)
|
check LibSQLite3.bind_blob(self, index, value, value.size, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue