From d65575cd77b95d55dd048e5f7052a37f88f23e4d Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Wed, 22 Jun 2016 14:13:44 -0300 Subject: [PATCH] update Slice(UInt8) to Bytes --- spec/driver_spec.cr | 10 +++++----- src/sqlite3/result_set.cr | 6 +++--- src/sqlite3/statement.cr | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/driver_spec.cr b/spec/driver_spec.cr index da0591c..bbf3212 100644 --- a/spec/driver_spec.cr +++ b/spec/driver_spec.cr @@ -114,7 +114,7 @@ describe Driver do it "executes and selects blob" do 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]) end end @@ -122,7 +122,7 @@ describe Driver do it "executes with bind blob" do with_db do |db| 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) end end @@ -161,7 +161,7 @@ describe Driver do rs.column_type(0).should eq(String) rs.column_type(1).should eq(Int64) 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 @@ -193,9 +193,9 @@ describe Driver do ary = UInt8[0x53, 0x51, 0x4C, 0x69, 0x74, 0x65] 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) end end diff --git a/src/sqlite3/result_set.cr b/src/sqlite3/result_set.cr index 53001a5..69c2841 100644 --- a/src/sqlite3/result_set.cr +++ b/src/sqlite3/result_set.cr @@ -52,13 +52,13 @@ class SQLite3::ResultSet < DB::ResultSet moving_column { |col| LibSQLite3.column_double(self, col) } end - def read(t : Slice(UInt8).class) : Slice(UInt8) + def read(t : Bytes.class) : Bytes moving_column do |col| blob = LibSQLite3.column_blob(self, col) bytes = LibSQLite3.column_bytes(self, col) ptr = Pointer(UInt8).malloc(bytes) ptr.copy_from(blob, bytes) - Slice(UInt8).new(ptr, bytes) + Bytes.new(ptr, bytes) end end @@ -74,7 +74,7 @@ class SQLite3::ResultSet < DB::ResultSet case LibSQLite3.column_type(self, index) when Type::INTEGER; Int64 when Type::FLOAT ; Float64 - when Type::BLOB ; Slice(UInt8) + when Type::BLOB ; Bytes when Type::TEXT ; String when Type::NULL ; Nil else diff --git a/src/sqlite3/statement.cr b/src/sqlite3/statement.cr index 52cb3ab..57d4f9d 100644 --- a/src/sqlite3/statement.cr +++ b/src/sqlite3/statement.cr @@ -52,7 +52,7 @@ class SQLite3::Statement < DB::Statement check LibSQLite3.bind_text(self, index, value, value.bytesize, nil) 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) end