Hi list.
I’m writing a program that stores a lot of Floats into MySQL database.
Simplified version of the program use the following form of class.
class Val < ActiveRecord::BASE
end
And Vals table contains one column:
num double
One of my data contains -Infinity for num and when I try to
Val.new
Val.num = <- Here goes -Inifinity
Val.save!
Then the program crashes:
“/usr/local/stow/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
log': Mysql::Error: Unknown column 'Infinity' in 'field list': INSERT INTO full_doc_indices (
etf,
Id,
phonemes,
filename,
end_time,
start_time`) VALUES(-Infinity, NULL, ‘IH N T IH’, ‘BN99EN_2’,
4952.77044, 4939.515) (ActiveRecord::StatementInvalid)”
Obviously, ActiveRecord is using “-Infinity” literally, and then MySQL
treats “-Infinity” as column name as the message shows. How can I handle
-Infinity then? I really have to store -Infinity anyway.
Thanks.
Sincerely,
Minkoo S.