Using version 2.7.3, the following script will raise an exception with the message "undefined method `[]'
for nil:NilClass" from the column_info method:
require 'dbi'
::DBI::connect('dbi:Mysql:host=localhost', 'my_user', 'my_password') do |dbh|
dbh.select_all("SHOW FULL PROCESSLIST") do |row|
puts row.inspect
end
end
My solution was to add the following after the require to auto-coerce unknown types to String:
# This fixes a bug in the library where an unknown type will cause
# exceptions to be raised, rather than using a reasonable default: String
# coercion.
require 'DBD/Mysql/Mysql'
class DBI::DBD::Mysql::Database
TYPE_MAP.default = TYPE_MAP[nil] if TYPE_MAP.default.nil?
end
|