aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMelanie Gilman <melanie@thoughtbot.com>2014-12-03 13:04:02 -0500
committerMelanie Gilman <melanie@thoughtbot.com>2014-12-03 13:20:56 -0500
commit286ab9b606f726787bbfdf8d426380d4b42e65f1 (patch)
treec0bf8615a671c49190afbfbfae41b675d7af1f6b /activerecord
parent6613716ad7d6fe68dc65dff52694e2d5e72ca2fc (diff)
downloadrails-286ab9b606f726787bbfdf8d426380d4b42e65f1.tar.gz
rails-286ab9b606f726787bbfdf8d426380d4b42e65f1.tar.bz2
rails-286ab9b606f726787bbfdf8d426380d4b42e65f1.zip
Move PredicateBuilder instantiation to constructor
In order to maintain thread safety and prevent race condition from memoization.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index cfbd3076cb..daafb0b645 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -26,6 +26,7 @@ module ActiveRecord
@values = values
@offsets = {}
@loaded = false
+ @predicate_builder = PredicateBuilder.new(klass, table)
end
def initialize_copy(other)
@@ -632,6 +633,10 @@ module ActiveRecord
"#<#{self.class.name} [#{entries.join(', ')}]>"
end
+ protected
+
+ attr_reader :predicate_builder
+
private
def exec_queries
@@ -677,9 +682,5 @@ module ActiveRecord
# ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries
string.scan(/([a-zA-Z_][.\w]+).?\./).flatten.map(&:downcase).uniq - ['raw_sql_']
end
-
- def predicate_builder
- @predicate_builder ||= PredicateBuilder.new(klass, table)
- end
end
end