diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-12-29 11:16:16 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-12-29 11:16:16 -0700 |
commit | 7931c96338353adc0ebfc780769ef3cd06ab0d79 (patch) | |
tree | 9bc3ba2a26b385dcb7d79ca1d57f24366be92f52 /activerecord/lib/active_record/associations/join_dependency.rb | |
parent | 848cba13bd8a1fd7445458160a15dbf175c4c61d (diff) | |
download | rails-7931c96338353adc0ebfc780769ef3cd06ab0d79.tar.gz rails-7931c96338353adc0ebfc780769ef3cd06ab0d79.tar.bz2 rails-7931c96338353adc0ebfc780769ef3cd06ab0d79.zip |
Pass a type caster when aliasing tables for joins
Diffstat (limited to 'activerecord/lib/active_record/associations/join_dependency.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 6c1c700d54..66e997c3c8 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -94,7 +94,7 @@ module ActiveRecord # def initialize(base, associations, joins) @alias_tracker = AliasTracker.create(base.connection, joins) - @alias_tracker.aliased_table_for(base.table_name, base.table_name) # Updates the count for base.table_name to 1 + @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 tree = self.class.make_tree associations @join_root = JoinBase.new base, build(tree, base) @join_root.children.each { |child| construct_tables! @join_root, child } @@ -186,9 +186,13 @@ 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) + table_alias_for(reflection, parent, reflection != node.reflection), + type_caster: type_caster, ) } end |