File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -95,14 +95,13 @@ def delete_hierarchy_references
9595 # See http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html
9696 # Also: PostgreSQL doesn't support INNER JOIN on DELETE, so we can't use that.
9797 _ct . connection . execute <<-SQL . strip_heredoc
98- DELETE FROM #{ _ct . quoted_hierarchy_table_name }
99- WHERE descendant_id IN (
100- SELECT DISTINCT descendant_id
101- FROM (SELECT descendant_id
102- FROM #{ _ct . quoted_hierarchy_table_name }
103- WHERE ancestor_id = #{ _ct . quote ( id ) }
104- OR descendant_id = #{ _ct . quote ( id ) }
105- ) #{ _ct . t_alias_keyword } x )
98+ DELETE #{ _ct . quoted_hierarchy_table_name } FROM #{ _ct . quoted_hierarchy_table_name }
99+ JOIN (
100+ SELECT descendant_id FROM #{ _ct . quoted_hierarchy_table_name }
101+ WHERE ancestor_id = #{ _ct . quote ( id ) }
102+ OR descendant_id = #{ _ct . quote ( id ) }
103+ ) #{ _ct . t_alias_keyword } x
104+ ON x.descendant_id = #{ _ct . quoted_hierarchy_table_name } .descendant_id
106105 SQL
107106 end
108107 end
You can’t perform that action at this time.
0 commit comments