diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-14 17:24:28 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-14 17:24:28 -0800 |
commit | 7d14e03d71861fac7926119dab903c984b89b568 (patch) | |
tree | 330c883257fb23673071401cc361a4b4974ac2e1 /activerecord | |
parent | 03118bc5afe99aaaf463a834d8a1ae16c918f6e8 (diff) | |
download | rails-7d14e03d71861fac7926119dab903c984b89b568.tar.gz rails-7d14e03d71861fac7926119dab903c984b89b568.tar.bz2 rails-7d14e03d71861fac7926119dab903c984b89b568.zip |
reorder bind indexes if joins produced bind values
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 159ad1dbe3..ffcdcd1169 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -844,6 +844,15 @@ module ActiveRecord arel.from(build_from) if from_value arel.lock(lock_value) if lock_value + # Reorder bind indexes if joins produced bind values + if arel.bind_values.any? + bvs = arel.bind_values + bind_values + arel.ast.grep(Arel::Nodes::BindParam).each_with_index do |bp, i| + column = bvs[i].first + bp.replace connection.substitute_at(column, i) + end + end + arel end |