diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 15:23:29 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-07 15:25:16 -0800 |
commit | ddbd2039615ca4376a46a97a17612732f24568cd (patch) | |
tree | 6de48872e320972dc24e59b4e214152ef6ed5608 /activerecord | |
parent | 1ce9b73e5c7cbf6c29c57bb60c97eb2d2c10801d (diff) | |
download | rails-ddbd2039615ca4376a46a97a17612732f24568cd.tar.gz rails-ddbd2039615ca4376a46a97a17612732f24568cd.tar.bz2 rails-ddbd2039615ca4376a46a97a17612732f24568cd.zip |
reduce string objects, reduce method calls
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/class_methods/join_dependency.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb index 9f171f891d..34928bc764 100644 --- a/activerecord/lib/active_record/associations/class_methods/join_dependency.rb +++ b/activerecord/lib/active_record/associations/class_methods/join_dependency.rb @@ -10,7 +10,7 @@ module ActiveRecord def initialize(base, associations, joins) @active_record = base - @table_joins = joins || '' + @table_joins = joins @join_parts = [JoinBase.new(base)] @associations = {} @reflections = [] @@ -45,12 +45,13 @@ module ActiveRecord end def count_aliases_from_table_joins(name) + return 0 unless @table_joins + # quoted_name should be downcased as some database adapters (Oracle) return quoted name in uppercase quoted_name = active_record.connection.quote_table_name(name.downcase).downcase join_sql = @table_joins.downcase - join_sql.blank? ? 0 : - # Table names - join_sql.scan(/join(?:\s+\w+)?\s+#{quoted_name}\son/).size + + # Table names + join_sql.scan(/join(?:\s+\w+)?\s+#{quoted_name}\son/).size + # Table aliases join_sql.scan(/join(?:\s+\w+)?\s+\S+\s+#{quoted_name}\son/).size end |