extend sqlite with time (as text) support.

This commit is contained in:
Brian J. Cardiff 2016-06-22 16:17:47 -03:00
parent d65575cd77
commit 497379ff81
4 changed files with 38 additions and 1 deletions

View file

@ -25,6 +25,7 @@ def sqlite_type_for(v)
when String ; "text"
when Int32, Int64 ; "int"
when Float32, Float64; "float"
when Time ; "text"
else
raise "not implemented for #{typeof(v)}"
end
@ -200,6 +201,24 @@ describe Driver do
end
end
it "insert/get value date from table" do
with_db do |db|
value = Time.new(2016, 7, 22, 15, 0, 0, 0)
db.exec "create table table1 (col1 #{sqlite_type_for(value)})"
db.exec %(insert into table1 values (?)), value
db.query "select col1 from table1" do |rs|
rs.move_next
rs.read(Time).should eq(value)
end
db.query "select col1 from table1" do |rs|
rs.move_next
rs.read?(Time).should eq(value)
end
end
end
it "raises on unsupported param types" do
with_db do |db|
expect_raises Exception, "SQLite3::Statement does not support NotSupportedType params" do