Skip to content

Can't destroy object for version 6.0.0 #206

@xiaohui-zhangxh

Description

@xiaohui-zhangxh

Please see below output, am I missing something to configure model?

module Catalog class Menu < ActiveRecord::Base acts_as_tree dependent: :destroy end end 
2.2.1 :002 > Catalog::Menu.find(4).destroy Catalog::Menu Load (0.4ms) SELECT `catalog_menus`.* FROM `catalog_menus` WHERE `catalog_menus`.`id` = 4 LIMIT 1 (0.2ms) BEGIN (0.3ms) SELECT GET_LOCK('ClosureTree::Catalog::Menu', 0) AS t457e5acb1b089fcf2c797b4a5f36d844 (12.3ms) DELETE FROM `catalog_menu_hierarchies` WHERE descendant_id IN ( SELECT DISTINCT descendant_id FROM (SELECT descendant_id FROM `catalog_menu_hierarchies` WHERE ancestor_id = 4 OR descendant_id = 4 ) AS x ) (0.3ms) SELECT RELEASE_LOCK('ClosureTree::Catalog::Menu') AS t5d47f4adccd01cbd21808d1b3cb19864 (5.3ms) ROLLBACK ActiveRecord::StatementInvalid: Mysql2::Error: You can't specify target table 'catalog_menu_hierarchies' for update in FROM clause: DELETE FROM `catalog_menu_hierarchies` WHERE descendant_id IN ( SELECT DISTINCT descendant_id FROM (SELECT descendant_id FROM `catalog_menu_hierarchies` WHERE ancestor_id = 4 OR descendant_id = 4 ) AS x ) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions