fix(mysql): improve create database permission hint

This commit is contained in:
zipg
2026-07-21 11:22:51 +08:00
committed by GitHub
parent 5847f242de
commit 7d41e4123f
10 changed files with 63 additions and 5 deletions
@@ -0,0 +1,13 @@
import type { DatabaseType } from "@/types/database";
type Translate = (key: string) => string;
function isMysqlCreateDatabaseAccessDenied(message: string): boolean {
return /\b1044\b/i.test(message) || /access denied for user[\s\S]*to database/i.test(message);
}
export function appendCreateDatabaseErrorHint(databaseType: DatabaseType | undefined, message: string, t: Translate): string {
if (databaseType !== "mysql" || !isMysqlCreateDatabaseAccessDenied(message)) return message;
const hint = t("contextMenu.mysqlCreateDatabasePermissionHint");
return message.includes(hint) ? message : `${message}\n\n${hint}`;
}