New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#count on decimal column returns BigDecimal #784
Comments
Imported from Lighthouse. Verified on Ubuntu + sqlite3 |
Imported from Lighthouse. Added patch. Contains broken unit test and code to fix it. |
Imported from Lighthouse. I could not replicate this problem with Rails 3.0.4 on Mac OS 10.6 with ruby 1.9.2p136 Steps:
As such, I did not try the patch. If this only happens on specific versions of rails, let me know and I'll test on them, as well. |
Imported from Lighthouse. Hey qertoip, Is this a DB specific issue? or were the sqlite tests also failing with your test case? Josh |
Imported from Lighthouse. As per Josh K's request, I checked the same setup as above in Postgres. (Postgres 9.0.3 on aforementioned platform: Rails 3.0.4 on Mac OS 10.6 with ruby 1.9.2p136) The outcome is the same: Salary.count(:amount).class => Fixnum Where Salary.amount is a decimal column in the migration, a 'numeric' type in the database itself (default behaviour). Cheers, |
Imported from Lighthouse. Hey qertoip and Jarrett, I am marking this issue as need-more-info until more information is supplied on how to replicate the issue. Thanks, Josh |
Imported from Lighthouse. It looks like a different patch was applied to fix a similar problem that also fixed this problem - see ticket 6103. If I'm reading the git history correctly, this was fixed on Jan 10, 2011. The unit test in my patch file now passes. (Although there is no such unit test currently in 3.0.4.) |
Imported from Lighthouse. Hi Jarrett, Thanks for looking into this, can you please create a new patch which only includes a test to make sure this does not break in the future. I will then get José or Santiago to look into it further. Thanks Josh |
Imported from Lighthouse. Added patch file with just the unit test. |
Imported from Lighthouse. We use Rails w/ Oracle and have also started seeing that Model.count returns BigDecimal, as opposed to Integer. Seems this was introduced with Rails 2.3.8 and persists in 2.3.11. |
Attachments saved to Gist: http://gist.github.com/971749 |
Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6158
Created by qertoip - 2010-12-13 15:44:24 UTC
Salary.count( :amount ) # => BigDecimal instead of Fixnum
The text was updated successfully, but these errors were encountered: