I have an application on Rails 3.0.3 accessing a legacy MySQL database with a float column. It appears that upgrading to Rails 3.1.3 causes some values of this column to be interpreted differently. I am using REE 1.8.7 2011.03 and the mysql 2.8.1 gem. I don't see anything obvious changing in my Gemfile.lock that could be responsible for this (for instance, using a different version of the mysql adapter).
ree-1.8.7-2011.03 :025 > OrderCardItem.find(72788).rods_sort
ree-1.8.7-2011.03 :001 > OrderCardItem.find(72788).rods_sort
I understand that there are a lot of idiosyncrasies inherent in floating point representation, but this is reproducible and looks like the result of some change between these version of Rails. I've looked through the git history and haven't been able to find anything.
Any help appreciated...thanks.
Can you select this row via the mysql command line interface and paste the output? I believe it's due to a difference between how mysql rounds floats and how ruby rounds floats.
mysql> select rods_sort from order_card_items where id = 72788;
| rods_sort |
| 0.01 |
We have the same problem in our apps just migrated to rails 3.1
Did you find the solution?
Using mysql2 adapter everything works fine again. :)
This still doesn't explain why the behavior changed...
Looks like this is a problem in the mysql driver:
class Stmt; include Enumerable end
class Result; include Enumerable end
mysql = Mysql.init
mysql.real_connect 'localhost', 'root', '', 'testing', nil, nil, nil
CREATE TABLE IF NOT EXISTS tests
mysql.query 'delete from tests'
mysql.query 'insert into tests (fun_column) values (0.1)'
result = mysql.query 'select fun_column from tests'
stmt = mysql.prepare 'select fun_column from tests'
result = stmt.execute
So I guess you aren't concerned at all with why this behavior changed from one version of Rails to another?
Same Mysql driver is working fine with Rails3.0.10 but fails in 3.1.12, How can i get rid of it.