fix: correct match live menu seed sql
This commit is contained in:
@@ -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'
|
||||
);
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user