aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-21 19:13:04 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-10-21 19:13:04 -0200
commitb98c10c164ba6d17a84097f57ff529a95fec3935 (patch)
treeb77a7d036f6c0b010d6eefe7baa3c85e5c480982 /activerecord/lib
parenta595fc1c56e5e9f4620bf5f248c87e9cb1e31b2f (diff)
parenta2ed5d2381079716cf6224bc7b0538d318b264a2 (diff)
downloadrails-b98c10c164ba6d17a84097f57ff529a95fec3935.tar.gz
rails-b98c10c164ba6d17a84097f57ff529a95fec3935.tar.bz2
rails-b98c10c164ba6d17a84097f57ff529a95fec3935.zip
Merge pull request #12588 from jetthoughts/12586_subquery_with_unprepared_sql
Inline bind values for sub-queries generated for Relation in where Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index a53f034345..d01f0384b4 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -894,6 +894,13 @@ module ActiveRecord
def build_where(opts, other = [])
case opts
when String, Array
+ #TODO: Remove duplication with: /activerecord/lib/active_record/sanitization.rb:113
+ values = Hash === other.first ? other.first.values : other
+
+ values.grep(ActiveRecord::Relation) do |rel|
+ self.bind_values += rel.bind_values
+ end
+
[@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]
when Hash
opts = PredicateBuilder.resolve_column_aliases(klass, opts)