Permalink
Browse files

Rename active_relation_engine -> arel_engine and active_relation_tabl…

…e -> arel_table
  • Loading branch information...
1 parent 717a294 commit 5a52523a800c8a57d1ad80ad3a0ba81711cce38e @lifo lifo committed Jan 16, 2010
@@ -1961,7 +1961,7 @@ def set_target_and_inverse(join, association, record)
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 @@ def initialize(reflection, join_dependency, parent = nil)
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 @@ def association_join
]
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 @@ def association_join
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
@@ -1389,7 +1389,7 @@ def column_methods_hash #: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 @@ def merge_conditions(*conditions)
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 @@ def array_of_strings?(o)
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 @@ def expand_hash_conditions_for_aggregates(attrs)
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
@@ -85,7 +85,7 @@ def test_transactions_across_databases
end
def test_arel_table_engines
- assert_not_equal Entrant.active_relation_engine, Course.active_relation_engine
- assert_equal Entrant.active_relation_engine, Bird.active_relation_engine
+ assert_not_equal Entrant.arel_engine, Course.arel_engine
+ assert_equal Entrant.arel_engine, Bird.arel_engine
end
end

0 comments on commit 5a52523

Please sign in to comment.