diff options
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 16 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 20 |
2 files changed, 18 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index d6ecd0a5e3..b52b298027 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1961,7 +1961,7 @@ module ActiveRecord class JoinBase # :nodoc: attr_reader :active_record, :table_joins - delegate :table_name, :column_names, :primary_key, :reflections, :sanitize_sql, :active_relation_engine, :to => :active_record + delegate :table_name, :column_names, :primary_key, :reflections, :sanitize_sql, :arel_engine, :to => :active_record def initialize(active_record, joins = nil) @active_record = active_record @@ -2037,12 +2037,12 @@ module ActiveRecord def association_join return @join if @join - aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => active_relation_engine) - parent_table = Arel::Table.new(parent.table_name, :as => parent.aliased_table_name, :engine => active_relation_engine) + aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine) + parent_table = Arel::Table.new(parent.table_name, :as => parent.aliased_table_name, :engine => arel_engine) @join = case reflection.macro when :has_and_belongs_to_many - join_table = Arel::Table.new(options[:join_table], :as => aliased_join_table_name, :engine => active_relation_engine) + join_table = Arel::Table.new(options[:join_table], :as => aliased_join_table_name, :engine => arel_engine) fk = options[:foreign_key] || reflection.active_record.to_s.foreign_key klass_fk = options[:association_foreign_key] || klass.to_s.foreign_key @@ -2052,7 +2052,7 @@ module ActiveRecord ] when :has_many, :has_one if reflection.options[:through] - join_table = Arel::Table.new(through_reflection.klass.table_name, :as => aliased_join_table_name, :engine => active_relation_engine) + join_table = Arel::Table.new(through_reflection.klass.table_name, :as => aliased_join_table_name, :engine => arel_engine) jt_foreign_key = jt_as_extra = jt_source_extra = jt_sti_extra = nil first_key = second_key = as_extra = nil @@ -2121,12 +2121,12 @@ module ActiveRecord end def relation - aliased = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => active_relation_engine) + aliased = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine) if reflection.macro == :has_and_belongs_to_many - [Arel::Table.new(options[:join_table], :as => aliased_join_table_name, :engine => active_relation_engine), aliased] + [Arel::Table.new(options[:join_table], :as => aliased_join_table_name, :engine => arel_engine), aliased] elsif reflection.options[:through] - [Arel::Table.new(through_reflection.klass.table_name, :as => aliased_join_table_name, :engine => active_relation_engine), aliased] + [Arel::Table.new(through_reflection.klass.table_name, :as => aliased_join_table_name, :engine => arel_engine), aliased] else aliased end diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 6ecd5061d4..e84130f42e 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1389,7 +1389,7 @@ module ActiveRecord #:nodoc: def reset_column_information undefine_attribute_methods @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @inheritance_column = nil - @active_relation = @active_relation_engine = nil + @active_relation = @arel_engine = nil end def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc: @@ -1503,19 +1503,19 @@ module ActiveRecord #:nodoc: end def active_relation - @active_relation ||= Relation.new(self, active_relation_table) + @active_relation ||= Relation.new(self, arel_table) end - def active_relation_table(table_name_alias = nil) - Arel::Table.new(table_name, :as => table_name_alias, :engine => active_relation_engine) + def arel_table(table_name_alias = nil) + Arel::Table.new(table_name, :as => table_name_alias, :engine => arel_engine) end - def active_relation_engine - @active_relation_engine ||= begin + def arel_engine + @arel_engine ||= begin if self == ActiveRecord::Base Arel::Table.engine else - connection_handler.connection_pools[name] ? Arel::Sql::Engine.new(self) : superclass.active_relation_engine + connection_handler.connection_pools[name] ? Arel::Sql::Engine.new(self) : superclass.arel_engine end end end @@ -1623,7 +1623,7 @@ module ActiveRecord #:nodoc: end def type_condition - sti_column = active_relation_table[inheritance_column] + sti_column = arel_table[inheritance_column] condition = sti_column.eq(sti_name) subclasses.each{|subclass| condition = condition.or(sti_column.eq(subclass.sti_name)) } @@ -1963,8 +1963,8 @@ module ActiveRecord #:nodoc: def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name) attrs = expand_hash_conditions_for_aggregates(attrs) - table = Arel::Table.new(self.table_name, :engine => active_relation_engine, :as => default_table_name) - builder = PredicateBuilder.new(active_relation_engine) + table = Arel::Table.new(self.table_name, :engine => arel_engine, :as => default_table_name) + builder = PredicateBuilder.new(arel_engine) builder.build_from_hash(attrs, table).map(&:to_sql).join(' AND ') end alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions |