sqlite> .schema
CREATE TABLE IF NOT EXISTS "things"(id bigserial primary key, created_at text);
sqlite> select * from things;
1|2020-11-14 21:56:52
Code:
require "sqlite3"
DB.open("sqlite3:./test.db") do |db|
db.query "select * from things" do |rs|
rs.each do
puts "#{rs.read(Int64)}, #{rs.read(Time)}"
end
end
end
Output:
Unhandled exception: Unexpected char: '\u{0}' at 19: "2020-11-14 21:56:52>>" (Time::Format::Error)
from ../../../../usr/lib/crystal/time/format/parser.cr:558:11 in 'raise'
from ../../../../usr/lib/crystal/time/format/parser.cr:554:5 in 'raise'
from ../../../../usr/lib/crystal/time/format/parser.cr:474:9 in 'char'
from ../../../../usr/lib/crystal/time/format/pattern.cr:165:9 in 'check_char'
from ../../../../usr/lib/crystal/time/format/pattern.cr:8:18 in 'visit'
from ../../../../usr/lib/crystal/time/format.cr:83:5 in 'parse'
from ../../../../usr/lib/crystal/time/format.cr:81:3 in 'parse'
from ../../../../usr/lib/crystal/time.cr:1181:5 in 'parse'
from lib/sqlite3/src/sqlite3/result_set.cr:67:5 in 'read'
from test.cr:6:34 in '__crystal_main'
from ../../../../usr/lib/crystal/crystal/main.cr:105:5 in 'main_user_code'
from ../../../../usr/lib/crystal/crystal/main.cr:91:7 in 'main'
from ../../../../usr/lib/crystal/crystal/main.cr:114:3 in 'main'
from __libc_start_main
from _start
from ???
However, this is the timestamp format used by SQLite's current_timestamp, so not being able to parse it is a problem. I'm not sure if the appropriate solution is a change here or somewhere else, but I'm posting it here as a starting point.
Database:
Code:
Output:
However, this is the timestamp format used by SQLite's
current_timestamp
, so not being able to parse it is a problem. I'm not sure if the appropriate solution is a change here or somewhere else, but I'm posting it here as a starting point.Occurs on master branch.