aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-01-14 20:29:28 +0000
committerJon Leighton <j@jonathanleighton.com>2012-01-16 21:17:18 +0000
commitf6cc6651f2a32af42345641c3d17fc26ddb96b52 (patch)
treeac8ea6126bf781cdb486f9d2d2334cb68b6867de /activerecord/lib/active_record/associations/preloader
parentee7f66603573fd441f1522cc73ec0b7f56c4d1af (diff)
downloadrails-f6cc6651f2a32af42345641c3d17fc26ddb96b52.tar.gz
rails-f6cc6651f2a32af42345641c3d17fc26ddb96b52.tar.bz2
rails-f6cc6651f2a32af42345641c3d17fc26ddb96b52.zip
Avoid sanitize_sql when we can use Relation#where instead
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r--activerecord/lib/active_record/associations/preloader/association.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb
index 779f8164cc..253998fb23 100644
--- a/activerecord/lib/active_record/associations/preloader/association.rb
+++ b/activerecord/lib/active_record/associations/preloader/association.rb
@@ -95,8 +95,8 @@ module ActiveRecord
def build_scope
scope = klass.scoped
- scope = scope.where(process_conditions(options[:conditions]))
- scope = scope.where(process_conditions(preload_options[:conditions]))
+ scope = scope.where(interpolate(options[:conditions]))
+ scope = scope.where(interpolate(preload_options[:conditions]))
scope = scope.select(preload_options[:select] || options[:select] || table[Arel.star])
scope = scope.includes(preload_options[:include] || options[:include])
@@ -112,13 +112,11 @@ module ActiveRecord
scope
end
- def process_conditions(conditions)
+ def interpolate(conditions)
if conditions.respond_to?(:to_proc)
- conditions = klass.send(:instance_eval, &conditions)
- end
-
- if conditions
- klass.send(:sanitize_sql, conditions)
+ klass.send(:instance_eval, &conditions)
+ else
+ conditions
end
end
end