This project is archived and is in readonly mode.
Calculations break with multi-column :select argument
-
CancelProfileIsBroken
- Tag changed from activerecord, calculations, patch to activerecord, bugmash, calculations, patch
-
Michael Koziarski
- Assigned user set to Michael Koziarski
- Tag changed from activerecord, bugmash, calculations, patch to activerecord, calculations, patch
- Milestone cleared.
We can't just take the first column specified, while it works for your example it's not 'good enough' in general. Instead we need a way to fix it permanently
I'd question why we're even taking the :select key from find scopes. I've attached a patch that takes it from :count scopes instead.
I've attached a patch for this and would appreciate your feedback. Your fix would look like:
Account.with_scope(:find=>{:select=>"COS(id), SIN(id)"}, :count=>{:select=>"id"}) do -
Jeremy Kemper
- State changed from new to open
This is messy indeed. I'd almost see an error raised than let this slip through or get hacked around.
Michael, that fix works for count, but not the other calculations.
-
Michael Koziarski
OK, I agree on the error case, let's just raise an exception in the
event that the :select scope doesn't map onto the column_name -
Jeremy Kemper
- State changed from open to incomplete
