aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-16 16:02:30 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-16 16:02:30 +0530
commit5a52523a800c8a57d1ad80ad3a0ba81711cce38e (patch)
treeb7d3ee4aa5675f18029fae61684b5007fd484b79 /activerecord
parent717a2941e15b32d07cc456bb0d81742ecfc5b4a3 (diff)
downloadrails-5a52523a800c8a57d1ad80ad3a0ba81711cce38e.tar.gz
rails-5a52523a800c8a57d1ad80ad3a0ba81711cce38e.tar.bz2
rails-5a52523a800c8a57d1ad80ad3a0ba81711cce38e.zip
Rename active_relation_engine -> arel_engine and active_relation_table -> arel_table
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb16
-rwxr-xr-xactiverecord/lib/active_record/base.rb20
-rw-r--r--activerecord/test/cases/multiple_db_test.rb4
3 files changed, 20 insertions, 20 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
diff --git a/activerecord/test/cases/multiple_db_test.rb b/activerecord/test/cases/multiple_db_test.rb
index 6155bfd50a..bd51388e05 100644
--- a/activerecord/test/cases/multiple_db_test.rb
+++ b/activerecord/test/cases/multiple_db_test.rb
@@ -85,7 +85,7 @@ class MultipleDbTest < ActiveRecord::TestCase
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