From 0408e212ca224bb25159f3e6db2a9c64cdea1200 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Tue, 16 Dec 2014 14:26:45 -0500 Subject: Initialze `#alias_tracker` with base table name Instead of initializing an empty connection use the base table name instead. Split up and refactor `#create` to be 2 methods `#create` and `#create_with_joins`. Removes the need to update the count by 1 on initialzing a JoinDependency. --- activerecord/lib/active_record/associations/join_dependency.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations/join_dependency.rb') diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 66e997c3c8..634abfac96 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -93,8 +93,7 @@ module ActiveRecord # joins # => [] # def initialize(base, associations, joins) - @alias_tracker = AliasTracker.create(base.connection, joins) - @alias_tracker.aliased_table_for(base.table_name, base.table_name, type_caster: base.type_caster) # Updates the count for base.table_name to 1 + @alias_tracker = AliasTracker.create_with_joins(base.connection, base.table_name, joins) tree = self.class.make_tree associations @join_root = JoinBase.new base, build(tree, base) @join_root.children.each { |child| construct_tables! @join_root, child } -- cgit v1.2.3 From 39abe8355a56992b32ed95e1ea1eb588c0ad7a6f Mon Sep 17 00:00:00 2001 From: eileencodes Date: Mon, 29 Dec 2014 14:12:39 -0500 Subject: Move `#type_caster` to alias tracker initialize This moves the `#type_caster` from the `aliased_table_for` and into the initialize of the `alias_tracker`. --- activerecord/lib/active_record/associations/join_dependency.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record/associations/join_dependency.rb') diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 634abfac96..4b75370171 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -93,7 +93,7 @@ module ActiveRecord # joins # => [] # def initialize(base, associations, joins) - @alias_tracker = AliasTracker.create_with_joins(base.connection, base.table_name, joins) + @alias_tracker = AliasTracker.create_with_joins(base.connection, base.table_name, joins, base.type_caster) tree = self.class.make_tree associations @join_root = JoinBase.new base, build(tree, base) @join_root.children.each { |child| construct_tables! @join_root, child } @@ -185,13 +185,9 @@ module ActiveRecord def table_aliases_for(parent, node) node.reflection.chain.map { |reflection| - if reflection.klass - type_caster = reflection.klass.type_caster - end alias_tracker.aliased_table_for( reflection.table_name, - table_alias_for(reflection, parent, reflection != node.reflection), - type_caster: type_caster, + table_alias_for(reflection, parent, reflection != node.reflection) ) } end -- cgit v1.2.3