From 875a770c5a8df611371a750f4b9d8bfc43c21dfb Mon Sep 17 00:00:00 2001 From: hajimi Date: Sun, 21 Jun 2026 13:49:35 +0800 Subject: [PATCH] fix: correct match live menu seed sql --- docs/sql/insert_menu_match_live.sql | 2 +- qa/frontend/test_match_live_admin_static.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/sql/insert_menu_match_live.sql b/docs/sql/insert_menu_match_live.sql index 005de39..f04c0e5 100644 --- a/docs/sql/insert_menu_match_live.sql +++ b/docs/sql/insert_menu_match_live.sql @@ -2,7 +2,7 @@ INSERT INTO `la_system_menu` (`pid`, `type`, `name`, `icon`, `sort`, `perms`, `p SELECT parent.`id`, 'C', '直播线路管理', '', 0, 'match.matchLive/lists', 'match_live', 'match/lists/index', 'match/lists', '', 0, 0, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP() FROM `la_system_menu` parent WHERE parent.`perms` = 'match.match/lists' -WHERE NOT EXISTS ( + AND NOT EXISTS ( SELECT 1 FROM `la_system_menu` WHERE `perms` = 'match.matchLive/lists' ); diff --git a/qa/frontend/test_match_live_admin_static.py b/qa/frontend/test_match_live_admin_static.py index 31efa91..f78f8c5 100644 --- a/qa/frontend/test_match_live_admin_static.py +++ b/qa/frontend/test_match_live_admin_static.py @@ -20,6 +20,8 @@ def main() -> None: assert MENU_SQL.is_file(), f"missing menu seed file: {MENU_SQL}" menu_sql = MENU_SQL.read_text(encoding="utf-8") normalized_menu_sql = " ".join(menu_sql.split()) + first_insert_block = menu_sql.split(";", 1)[0] + ";" + normalized_first_insert = " ".join(first_insert_block.split()) assert_contains(MATCH_INDEX, 'type="expand"') assert_contains(MATCH_INDEX, "MatchLiveTable") @@ -118,8 +120,16 @@ def main() -> None: ), f"{MENU_SQL} must bind the match live menu to parent match.match/lists explicitly" assert ( "SELECT parent.`id`, 'C', '直播线路管理'" in menu_sql - and "WHERE NOT EXISTS (" in menu_sql ), f"{MENU_SQL} must insert the list menu only when the parent match.match/lists record exists" + assert ( + "WHERE parent.`perms` = 'match.match/lists' AND NOT EXISTS (" in normalized_first_insert + ), f"{MENU_SQL} first insert must combine parent binding with AND NOT EXISTS in a single WHERE predicate" + assert ( + "WHERE parent.`perms` = 'match.match/lists' WHERE NOT EXISTS (" not in normalized_first_insert + ), f"{MENU_SQL} first insert must not contain a second standalone WHERE NOT EXISTS after the parent WHERE" + assert normalized_first_insert.count("WHERE") == 2, ( + f"{MENU_SQL} first insert should only have the outer WHERE plus the nested WHERE inside NOT EXISTS" + ) assert ( "SELECT (SELECT `id` FROM `la_system_menu` WHERE `perms` = 'match.matchLive/lists' LIMIT 1)" in normalized_menu_sql ), f"{MENU_SQL} child permissions must bind to the inserted match.matchLive/lists menu"