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
And Vals table contains one column:
One of my data contains -Infinity for num and when I try to
Val.num = <- Here goes -Inifinity
Then the program crashes:
log': Mysql::Error: Unknown column 'Infinity' in 'field list': INSERT INTO full_doc_indices (etf
,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.