We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A column with a BLOB type, reads as whatever the type of the value is, as opposed to Bytes, which would make more sense.
BLOB
Bytes
DB.open "sqlite3://./data.db" do |db| db.exec "create table contacts (name text, data BLOG)" db.exec "insert into contacts values (?, ?)", "John Doe", 30 db.query "select name, data from contacts" do |rs| rs.each do puts "#{rs.read(String)} (#{rs.read(Bytes)})" end end end
SQLite3::ResultSet#read returned a Int64. A Slice(UInt8) was expected. (Exception)
Changing the 30 to "foo"
30
"foo"
SQLite3::ResultSet#read returned a String. A Slice(UInt8) was expected. (Exception)
The text was updated successfully, but these errors were encountered:
Sqlite3 is dynamically typed, and the type is associated with the data, not the column. If you want to read bytes, then you need to write bytes:
require "db" require "sqlite3" DB.open "sqlite3://./data.db" do |db| db.exec "create table contacts (name text, data blob)" db.exec "insert into contacts values (?, ?)", "John Doe", Bytes.new(6,8) db.query "select name, data from contacts" do |rs| rs.each do puts "#{rs.read(String)} (#{rs.read(Bytes)})" end end end #=> John Doe (Bytes[8, 8, 8, 8, 8, 8])
Sorry, something went wrong.
No branches or pull requests
A column with a
BLOB
type, reads as whatever the type of the value is, as opposed toBytes
, which would make more sense.SQLite3::ResultSet#read returned a Int64. A Slice(UInt8) was expected. (Exception)
Changing the
30
to"foo"
SQLite3::ResultSet#read returned a String. A Slice(UInt8) was expected. (Exception)
The text was updated successfully, but these errors were encountered: