feat(gbase8s): pick locale and charset when creating database

This commit is contained in:
弈秋 authored and GitHub committed 2026-09-16 21:37:34 +08:00
1 parent ea1de14517
commit 1d19c8b273
8 files changed
+190 -9

No files matched your search

@@ -10,6 +10,12 @@ export interface CreateDatabaseCharsetMetadata {
export const CREATE_DATABASE_CHARSET_OPTIONS = ["utf8mb4", "utf8", "gbk", "latin1", "ascii", "big5", "gb2312", "utf16", "utf32"] as const;
// Common GBase 8s / Informix database locales (language_territory.codeset). The default is a
// UTF-8 locale so newly created databases can store Chinese; en_US.819 is a typical Informix
// instance default and cannot hold CJK characters.
export const GBASE8S_DATABASE_LOCALES = ["zh_CN.utf8", "en_US.utf8", "ja_JP.utf8", "ko_KR.utf8", "zh_CN.gbk", "zh_CN.gb18030", "en_US.819"] as const;
export const DEFAULT_GBASE8S_DATABASE_LOCALE = "zh_CN.utf8";
const FALLBACK_COLLATION_OPTIONS: Record<string, string[]> = {
ascii: ["ascii_general_ci", "ascii_bin"],
big5: ["big5_chinese_ci", "big5_bin"],
@@ -18,6 +18,14 @@ export function supportsCreateDatabaseCharset(databaseType?: DatabaseType, drive
return MYSQL_COMPATIBLE_TYPES.has(databaseType as DatabaseType) || (!!driverProfile && MYSQL_COMPATIBLE_PROFILES.has(driverProfile.toLowerCase()));
}
// GBase 8s creates a database whose codeset follows the creating session's DB_LOCALE; there is
// no charset clause in the SQL. The create dialog still offers a locale picker, and the chosen
// value is applied by the gbase8s agent opening the CREATE DATABASE session with that DB_LOCALE.
// Plain Informix is excluded until InformixAgent learns to honor the locale directive.
export function supportsCreateDatabaseLocale(databaseType?: DatabaseType, driverProfile?: string | null): boolean {
return databaseType === "gbase" && driverProfile === "gbase8s";
}
export function buildCreateDatabaseSql(options: CreateDatabaseSqlOptions): Promise<string> {
return api.buildCreateDatabaseSql(options);
}