mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Cache sanitized conditions in reflection object for associations
This commit is contained in:
parent
0b12da44aa
commit
5ca7d01eca
2 changed files with 5 additions and 1 deletions
|
@ -85,7 +85,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def conditions
|
||||
@conditions ||= interpolate_sql(sanitize_sql(@reflection.options[:conditions])) if @reflection.options[:conditions]
|
||||
@conditions ||= interpolate_sql(@reflection.sanitized_conditions) if @reflection.sanitized_conditions
|
||||
end
|
||||
alias :sql_conditions :conditions
|
||||
|
||||
|
|
|
@ -112,6 +112,10 @@ module ActiveRecord
|
|||
name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record
|
||||
end
|
||||
|
||||
def sanitized_conditions #:nodoc:
|
||||
@sanitized_conditions ||= klass.send(:sanitize_sql, options[:conditions]) if options[:conditions]
|
||||
end
|
||||
|
||||
private
|
||||
def derive_class_name
|
||||
name.to_s.camelize
|
||||
|
|
Loading…
Reference in a new issue