diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-19 15:17:43 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-19 15:19:43 -0700 |
commit | 04d1c3716b5bfa133a0b1ed937649a0829ac5f22 (patch) | |
tree | 99bf898cfe3e93eeb4a31e931d642c222bb75a0f /activerecord/lib/active_record/relation/predicate_builder.rb | |
parent | 50a8cdf0e2cff604b0361a370afc8becf2579d94 (diff) | |
download | rails-04d1c3716b5bfa133a0b1ed937649a0829ac5f22.tar.gz rails-04d1c3716b5bfa133a0b1ed937649a0829ac5f22.tar.bz2 rails-04d1c3716b5bfa133a0b1ed937649a0829ac5f22.zip |
Fix bind value copying from subqueried relations
With the old implementation, the bind values were created, and then we
search the attributes for `Relation` objects, and merge them. This
completely ignores the order that the actual `where` clause will use. If
all non-relation where parameters are before the relations, it will
work. However, if we query on both a relation and a value, with the
value coming second, it breaks. The order of the hash should not affect
the final query (especially since hashes being ordered is an
implementation detail)
Diffstat (limited to 'activerecord/lib/active_record/relation/predicate_builder.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index f1cb4e1bee..2860a30f99 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -41,6 +41,8 @@ module ActiveRecord attrs, bvs = associated_predicate_builder(column_name).create_binds(value) result[column_name] = attrs binds += bvs + when Relation + binds += value.arel.bind_values + value.bind_values end end |