Relation subqueries #188

wants to merge 1 commit into


None yet
2 participants

pfenig 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 =>

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

Have corresponded with @tenderlove on this.

removed an unnecessary second query when passing an ActiveRecord::Rel…
…ation to a where clause. And added ability to use subselects in where clauses.

This comment has been minimized.

Show comment
Hide comment

tenderlove Feb 16, 2011


Merged to master and pushed. Thanks.


tenderlove commented Feb 16, 2011

Merged to master and pushed. Thanks.

mices referenced this pull request in adjust/streets Feb 23, 2017

Added :nodoc: for `attribute_changed?` and `attribute_was` [ci skip]
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 issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment