diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-09 10:29:13 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-09 10:31:23 -0700 |
commit | ec475547a94315ac207ac4e9bd8f2ac04576230c (patch) | |
tree | 87f24db8b3928bfcc0d5f1bc8295d815459f70dc /activerecord/test/cases/relation | |
parent | 13772bfa49325a8dc26410d2dcb555665a320f92 (diff) | |
download | rails-ec475547a94315ac207ac4e9bd8f2ac04576230c.tar.gz rails-ec475547a94315ac207ac4e9bd8f2ac04576230c.tar.bz2 rails-ec475547a94315ac207ac4e9bd8f2ac04576230c.zip |
Properly copy nested bind values from subqueried relations
This is cropping up all over the place. After a brief dive, I'm really
not sure why we have `arel.bind_values` at all. A cursory grep didn't
reveal where they're actually being assigned (it's definitely in AR, not
in Arel). I'd like to dig further into it, as I'm fairly certain we
don't actually need it, we just need a way for the predicate builder to
communicate merged binds upstream.
Fixes #18414
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r-- | activerecord/test/cases/relation/where_test.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb index d675953da6..b0573579da 100644 --- a/activerecord/test/cases/relation/where_test.rb +++ b/activerecord/test/cases/relation/where_test.rb @@ -1,13 +1,15 @@ require "cases/helper" -require 'models/author' -require 'models/price_estimate' -require 'models/treasure' -require 'models/post' -require 'models/comment' -require 'models/edge' -require 'models/topic' -require 'models/binary' -require 'models/vertex' +require "models/author" +require "models/binary" +require "models/cake_designer" +require "models/chef" +require "models/comment" +require "models/edge" +require "models/post" +require "models/price_estimate" +require "models/topic" +require "models/treasure" +require "models/vertex" module ActiveRecord class WhereTest < ActiveRecord::TestCase @@ -26,6 +28,16 @@ module ActiveRecord } end + def test_where_copies_arel_bind_params + chef = Chef.create! + CakeDesigner.create!(chef: chef) + + cake_designers = CakeDesigner.joins(:chef).where(chefs: { id: chef.id }) + chefs = Chef.where(employable: cake_designers) + + assert_equal [chef], chefs.to_a + end + def test_rewhere_on_root assert_equal posts(:welcome), Post.rewhere(title: 'Welcome to the weblog').first end |