You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 )
The text was updated successfully, but these errors were encountered:
Ok, I found the solution by my self. This error happens if MySQL is 5.7+, SET optimizer_switch = 'derived_merge=off' can get rid of error. or set my.cnf optimizer_switch=derived_merge=off under [mysqld] section.
Please see below output, am I missing something to configure model?
The text was updated successfully, but these errors were encountered: