Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add :from scoping respect to Calculations module

#1229

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.

Reported by John Wulff · October 16th, 2008 @ 11:43 PM

State: committed
Milestone: 2.3.4
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. Pratik
    Pratik
    • Milestone cleared.
    • State changed from new to incomplete
    • Assigned user set to Pratik

    Looks good. Missing tests.

    Thanks.

    January 18th, 2009 @ 06:33 AM

  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activerecord, calculations, named_scope, patch, scope to activerecord, bugmash, calculations, named_scope, patch, scope

    August 4th, 2009 @ 06:10 PM

  3. Matt Duncan
    Matt Duncan

    +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.

    August 8th, 2009 @ 03:58 AM

  4. José Valim
    José Valim
    • Assigned user changed from Pratik to Michael Koziarski
    • State changed from incomplete to new

    August 8th, 2009 @ 11:51 PM

  5. Matt Duncan
  6. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to open
    • Milestone set to 2.3.4

    Needs rebase against master.

    August 9th, 2009 @ 12:52 AM

  7. Jeremy Kemper
  8. Matt Duncan
    Matt Duncan

    I've attached a patch rebased against the current master.

    August 9th, 2009 @ 01:12 AM

  9. Matt Duncan
    Matt Duncan

    Lets try that again with the correct patch...

    August 9th, 2009 @ 01:32 AM

  10. Jeremy Kemper
    Jeremy Kemper

    Ah, Michael already committed this but didn't cherry-pick to 2-3-stable.

    August 9th, 2009 @ 01:59 AM

  11. Steve St. Martin
    Steve St. Martin

    so does this need a patch against 2-3-stable?

    August 9th, 2009 @ 02:13 AM

  12. Michael Koziarski
    Michael Koziarski

    Yes I did... github's just way behind.

    August 9th, 2009 @ 02:14 AM

  13. Michael Koziarski
    Michael Koziarski
    • Tag changed from activerecord, bugmash, calculations, named_scope, patch, scope to activerecord, calculations, named_scope, patch, scope
    • State changed from open to resolved

    August 9th, 2009 @ 02:14 AM

  14. Repository
    Repository
    • State changed from resolved to committed

    August 9th, 2009 @ 05:26 AM

  15. Repository