mysql - rails: order query by big decimal attribute -
i've got active record model attribute of big decimal type. wanted able order respect attribute being treated number. instead i've got following:
1.9.1 :034 > y ball.order("radius desc").map{|b| b.radius} ball load (1.1ms) select `balls`.* `balls` order radius desc --- - 11.5 - 8.0 - 4.9 - 12.0 - 6.6 - 6.8 - 10.0 - 6.0 - 7.6 - 8.4
i'm wondering whether in rails there reasonable possibility perform ordering without introducing considerable changes in query.
works fine me, ruby-2.0.0-p0, 'rails', '3.2.13', , discount decimal, :precision => 8, :scale => 2, :default => 0.0
y project.order("discount desc").map{|p| p.discount } project load (2.4ms) select `projects`.* `projects` order discount desc --- - 35.3 - 5.3 - 2.9 - 2.3 - 0.0
Comments
Post a Comment