As a work around, try *not* setting type_translation.
SQLite3::Database#type_translation= is being deprecated anyway.
>>> stmt = "select * from ausgaben where monat = 7"
> => "select * from ausgaben where monat = 7"
>>> row = db.get_first_row(stmt)
> => [2010, 7, "jo", 245.93, "miete zimmer", false]
>>> row.fields
> => ["jahr", "monat", "name", "betrag", "tags", "gemeinsam"]
>>> row.columns
> NoMethodError: undefined method `columns' for [2010, 7, "jo", 245.93,
> "miete zimmer", false]:SQLite3::ResultSet::ArrayWithTypesAndFields
> from (irb):7
> from /usr/bin/irb:12:in `<main>'
This object does not respond to columns.
>>> db.results_as_hash = true
> => true
>>> row = db.get_first_row(stmt)
> NoMethodError: undefined method `columns' for #<Array:
> 0x0000000132fa98>
> from /usr/lib/ruby/site_ruby/1.9.1/sqlite3/database.rb:134:in `block
> (2 levels) in execute'
> from /usr/lib/ruby/site_ruby/1.9.1/sqlite3/database.rb:132:in `each'
> from /usr/lib/ruby/site_ruby/1.9.1/sqlite3/database.rb:132:in `block
> in execute'
> from /usr/lib/ruby/site_ruby/1.9.1/sqlite3/database.rb:87:in
> `prepare'
> from /usr/lib/ruby/site_ruby/1.9.1/sqlite3/database.rb:125:in
> `execute'
> from /usr/lib/ruby/site_ruby/1.9.1/sqlite3/database.rb:274:in
> `get_first_row'
> from (irb):9
> from /usr/bin/irb:12:in `<main>'
The above call should work if you don't set type_translation to true.
> Hoping that's only a simple bug - or that I used your library wrong!
> Please tell me, if I should provide more information.
This was enough information to reproduce the bug, thanks! For now you
should be able to work around the problem by not setting type
translation. I've fixed the bug here:
http://github.com/luislavena/sqlite3-ruby/commit/685a7f1126aac82572de79d3d8b06023f850b418
But please note that SQLite3::Database#type_translation= is being deprecated.
--
Aaron Patterson
http://tenderlovemaking.com/