[MacRuby] #1030: A potential SQLite3-Ruby bug
MacRuby
ruby-noreply at macosforge.org
Mon Dec 6 19:50:14 PST 2010
#1030: A potential SQLite3-Ruby bug
----------------------------------+-----------------------------------------
Reporter: yasuimao@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
----------------------------------+-----------------------------------------
I encountered a potential bug with SQLite3-Ruby. I installed SQLite3-Ruby
with macgem. The version of SQLite is the one on the system (3.6.12) and
the version of SQLite3-Ruby is 1.3.2.
I'm not sure if this is specific on my system or a bug.
sqlite3 test.rb
{{{
#!/usr/local/bin/macruby
require "rubygems"
require "sqlite3"
sql = <<-SQL
CREATE table test_table (
col1 integer,
col2 integer,
col3 integer
);
SQL
db = SQLite3::Database.new("test.db")
db.transaction do
db.execute("DROP TABLE test_table") if db.execute("SELECT tbl_name FROM
sqlite_master WHERE type == 'table'").include?(["test_table"])
db.execute(sql)
db.execute("INSERT into test_table (col1,col2,col3) values
(?,?,?)",0,0,0)
p db.execute("SELECT col1,col2,col3 FROM test_table")
end
}}}
Results
MacRuby 0.8 nightly
{{{
#=> [[nil, 0, 0]]
}}}
Ruby 1.8.7
{{{
#=> [[0,0,0]]
}}}
If there are more than two items (into two columns) in this way, the first
item to insert (not the first column on the table) is always nil. If
values are in the command string using #{} or only one item is inserted,
no issue.
{{{
db.execute("INSERT into test_table (col1,col2,col3) values (0,0,0)")
OR
db.execute("INSERT into test_table (col1,col2,col3) values
(#{0},#{0},#{0})")
}}}
Result - MacRuby 0.8 nightly, Ruby 1.8.7
{{{
#=> [[0,0,0]]
}}}
I'll see if I can attach this sample script file.
--
Ticket URL: <http://www.macruby.org/trac/ticket/1030>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list