diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-04 19:59:58 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-03-04 19:59:58 -0800 |
commit | ef7e7ad7e9c11916865b7e3e9f0c754a4e6fc775 (patch) | |
tree | f26982595a12baeede08963ccf90da1250186714 /activerecord/lib | |
parent | ccf8f27dddcc36fa5c91f614647e0b0bac861d83 (diff) | |
parent | f317cc8bc007978d7b135ddd1acdd7e3d1e582a3 (diff) | |
download | rails-ef7e7ad7e9c11916865b7e3e9f0c754a4e6fc775.tar.gz rails-ef7e7ad7e9c11916865b7e3e9f0c754a4e6fc775.tar.bz2 rails-ef7e7ad7e9c11916865b7e3e9f0c754a4e6fc775.zip |
Merge pull request #14261 from MSch/bound-parameters-for-exists
Make exists? use bound values.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 7099bdd285..1ba7fc47c0 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -292,7 +292,12 @@ module ActiveRecord when Array, Hash relation = relation.where(conditions) else - relation = relation.where(table[primary_key].eq(conditions)) if conditions != :none + if conditions != :none + column = columns_hash[primary_key] + substitute = connection.substitute_at(column, bind_values.length) + relation = where(table[primary_key].eq(substitute)) + relation.bind_values += [[column, conditions]] + end end connection.select_value(relation, "#{name} Exists", relation.bind_values) ? true : false |