Skip to content
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

AR::Relation.select does not remove calculated attributes #9

Open
lowjoel opened this issue Apr 7, 2016 · 0 comments
Open

AR::Relation.select does not remove calculated attributes #9

lowjoel opened this issue Apr 7, 2016 · 0 comments

Comments

@lowjoel
Copy link
Contributor

lowjoel commented Apr 7, 2016

Reducing my use case (not really tested, let me know if this needs clarification)

class SomeModel < ActiveRecord::Base
  has_many :children
  calculated :some_attribute, -> { ... }
  scope :with_other_model do
    select(:id)
  end

  default_scope { calculated(:some_attribute }
end

# Usage:
SomeModel.with_other_model # => SELECT id, (...) AS some_attribute ...

This affects the ability to use a scope with calculated attributes as a subquery. I'd imagine the calculated attributes would need to be removed if a select is applied onto the scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant