This project is archived and is in readonly mode.
Add :from scoping respect to Calculations module
Reported by John Wulff | October 16th, 2008 @ 11:43 PM | in 2.3.4
Calculations do not respect :from scopings. (The do now respect :from as an option.)
class Node < ActiveRecord::Base
named_scope :old_nodes, { :from => 'old_nodes' }
end
Node.old_nodes.average(:value)
executes:
SELECT avg("nodes".value) AS avg_value FROM "nodes"
it should respect the scope and execute:
SELECT avg("nodes".value) AS avg_value FROM "old_nodes"
I've attached a fix.
Comments and changes to this ticket
-
Pratik January 18th, 2009 @ 06:33 AM
- Milestone cleared.
- State changed from new to incomplete
- Assigned user set to Pratik
Looks good. Missing tests.
Thanks.
-
CancelProfileIsBroken August 4th, 2009 @ 06:10 PM
- Tag changed from activerecord, calculations, named_scope, patch, scope to activerecord, bugmash, calculations, named_scope, patch, scope
-
Matt Duncan August 8th, 2009 @ 03:58 AM
+1 Although I don't see a lot of use-cases for this I think it's good to be consistent. I've added a test, if anyone has thoughts on how this could be better tested please let me know.
I've attached a patch.
-
José Valim August 8th, 2009 @ 11:51 PM
- Assigned user changed from Pratik to Michael Koziarski
- State changed from incomplete to new
-
Jeremy Kemper August 9th, 2009 @ 12:52 AM
- State changed from new to open
- Milestone set to 2.3.4
Needs rebase against master.
-
Jeremy Kemper August 9th, 2009 @ 01:59 AM
Ah, Michael already committed this but didn't cherry-pick to 2-3-stable.
-
Michael Koziarski August 9th, 2009 @ 02:14 AM
- Tag changed from activerecord, bugmash, calculations, named_scope, patch, scope to activerecord, calculations, named_scope, patch, scope
- State changed from open to resolved
-
Repository August 9th, 2009 @ 05:26 AM
- State changed from resolved to committed
(from [3b3798506b403911665c3c24fd055b75d6f6a44f]) Adding :from scoping to ActiveRecord calculations
Signed-off-by: Michael Koziarski michael@koziarski.com
[#1229 state:committed] http://github.com/rails/rails/commit/3b3798506b403911665c3c24fd055b... -
Repository August 9th, 2009 @ 05:27 AM
(from [45f5bdfbc7fc1ee1fbc23525a112062c8b31d539]) Adding :from scoping to ActiveRecord calculations
Signed-off-by: Michael Koziarski michael@koziarski.com
[#1229 state:committed] http://github.com/rails/rails/commit/45f5bdfbc7fc1ee1fbc23525a11206...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1229 Add :from scoping respect to Calculations module Signed-off-by: Michael Koziarski michael@koziarski.com [#...
- 1229 Add :from scoping respect to Calculations module Signed-off-by: Michael Koziarski michael@koziarski.com [#...