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

Relation subqueries #188

Closed
wants to merge 1 commit into from
Closed

Conversation

sfenig
Copy link

@sfenig sfenig commented Feb 11, 2011

ActiveRecord::Relation where clauses hash syntax accepts an ActiveRecord::Relation as a value, but it maps the relation to ids when it could just use a subquery. By converting the Relation to an ast we can now accept any subquery.

Model.where(:id => AnotherModel.some_scope.select(:some_id))

will only run one query and it supports references to tables from the outer query.

Have corresponded with @tenderlove on this.

…ation to a where clause. And added ability to use subselects in where clauses.
@tenderlove
Copy link
Member

Merged to master and pushed. Thanks.

mices referenced this pull request in adjust/streets Feb 23, 2017
These methods were made "public" in 47617ec so that `method_missing`
can invoke them without going through `send`, but they aren't meant
for consumption from outside of Rails.
This pull request was closed.
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

Successfully merging this pull request may close these issues.

None yet

2 participants