diff options
author | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-10-12 14:38:37 +0300 |
---|---|---|
committer | Paul Nikitochkin <paul.nikitochkin@gmail.com> | 2013-10-13 22:13:50 +0300 |
commit | bc293ff690e5478b99a55594f9fa8fe0e709941b (patch) | |
tree | 3f059f76dedbf144139369e9b735091909e112cb /activerecord/CHANGELOG.md | |
parent | 365110196afcf952bc22729d4467d579b708328f (diff) | |
download | rails-bc293ff690e5478b99a55594f9fa8fe0e709941b.tar.gz rails-bc293ff690e5478b99a55594f9fa8fe0e709941b.tar.bz2 rails-bc293ff690e5478b99a55594f9fa8fe0e709941b.zip |
Generate subquery for Relation passed as array condition for where
Instead of executing 2 queries for fetching records filtered by array condition with Relation,
added generation of subquery to current query.
This behaviour will be consistent when passes Relation as hash condition to where
Closes: #12415
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 83c94caa53..77ce30359c 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,20 @@ +* Generate subquery for `Relation` if it passed as array condition for `where` method + + Example: + # Before + Blog.where('id in (?)', Blog.where(id: 1)) + # => SELECT "blogs".* FROM "blogs" WHERE "blogs"."id" = 1 + # => SELECT "blogs".* FROM "blogs" WHERE (id IN (1)) + + # After + Blog.where('id in (?)', Blog.where(id: 1).select(:id)) + # => SELECT "blogs".* FROM "blogs" + # WHERE "blogs"."id" IN (SELECT "blogs"."id" FROM "blogs" WHERE "blogs"."id" = 1) + + Fixes: #12415 + + *Paul Nikitochkin* + * `has_and_belongs_to_many` is now transparently implemented in terms of `has_many :through`. Behavior should remain the same, if not, it is a bug. |