fix(gaussdb): support M-mode type metadata

This commit is contained in:
Andrew authored and GitHub committed 2026-08-12 02:05:54 +08:00
1 parent dbe3375739
commit 26bb10dad0
13 files changed
+904 -146

No files matched your search

@@ -153,3 +153,26 @@ function floatHelpKey(normalizedType: string): "real" | "double" | undefined {
if (value >= 1 && value <= 24) return "real";
return value >= 25 && value <= 53 ? "double" : undefined;
}
/**
* Converts a GaussDB M-mode PostgreSQL internal type name to its MySQL-style
* display name. Returns the original name if no conversion applies.
*
* GaussDB M mode returns PostgreSQL internal type names (e.g. bpchar, int4,
* numeric, int1) but should display MySQL-compatible names.
*/
export function gaussdbMTypeDisplayName(typeName: string): string {
const s = typeName.trim().toLowerCase();
if (s === "bpchar") return "char";
if (s === "int4" || s === "integer") return "int";
if (s === "int2" || s === "smallint") return "smallint";
if (s === "int8" || s === "bigint") return "bigint";
if (s === "int1") return "tinyint";
if (s === "numeric") return "decimal";
if (s === "float4" || s === "real") return "float";
if (s === "float8" || s === "double precision") return "double";
if (s === "bool" || s === "boolean") return "boolean";
if (s === "character varying") return "varchar";
if (s === "character") return "char";
return typeName;
}