Skip to content

Commit 1a37b40

Browse files
author
William Shupe
committed
Fix hierarchy cleanup error when using type_caster
This commit fixes an issue where a database proxy tries to access the type_caster on the aliased arel table. Since this is just an alias table of the current model, it makes sense to use the current model's type_caster for the alias.
1 parent 7ee5ab3 commit 1a37b40

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/closure_tree/hierarchy_maintenance.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def cleanup!
123123

124124
[:descendant_id, :ancestor_id].each do |foreign_key|
125125
alias_name = foreign_key.to_s.split('_').first + "s"
126-
alias_table = Arel::Table.new(table_name).alias(alias_name)
126+
alias_table = Arel::Table.new(table_name, type_caster: type_caster).alias(alias_name)
127127
arel_join = hierarchy_table.join(alias_table, Arel::Nodes::OuterJoin)
128128
.on(alias_table[primary_key].eq(hierarchy_table[foreign_key]))
129129
.join_sources

0 commit comments

Comments
 (0)