fix: correct match live menu seed sql

This commit is contained in:
hajimi
2026-06-21 13:49:35 +08:00
parent 229b70c1be
commit 875a770c5a
2 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -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() 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 FROM `la_system_menu` parent
WHERE parent.`perms` = 'match.match/lists' WHERE parent.`perms` = 'match.match/lists'
WHERE NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM `la_system_menu` SELECT 1 FROM `la_system_menu`
WHERE `perms` = 'match.matchLive/lists' WHERE `perms` = 'match.matchLive/lists'
); );
+11 -1
View File
@@ -20,6 +20,8 @@ def main() -> None:
assert MENU_SQL.is_file(), f"missing menu seed file: {MENU_SQL}" assert MENU_SQL.is_file(), f"missing menu seed file: {MENU_SQL}"
menu_sql = MENU_SQL.read_text(encoding="utf-8") menu_sql = MENU_SQL.read_text(encoding="utf-8")
normalized_menu_sql = " ".join(menu_sql.split()) 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, 'type="expand"')
assert_contains(MATCH_INDEX, "MatchLiveTable") 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" ), f"{MENU_SQL} must bind the match live menu to parent match.match/lists explicitly"
assert ( assert (
"SELECT parent.`id`, 'C', '直播线路管理'" in menu_sql "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" ), 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 ( assert (
"SELECT (SELECT `id` FROM `la_system_menu` WHERE `perms` = 'match.matchLive/lists' LIMIT 1)" in normalized_menu_sql "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" ), f"{MENU_SQL} child permissions must bind to the inserted match.matchLive/lists menu"