From 5bc168f20c993f5b6ae7af396f7873edce39fac5 Mon Sep 17 00:00:00 2001 From: ptma Date: Sat, 20 Jun 2026 22:10:26 +0800 Subject: [PATCH] fix(postgres): strip length from fixed-size types and fix SQL library UX issues * fix(postgre): Fix the data type syntax when creating tables in PostgreSQL * fix(ui): Save the state when closing the SQL library through the close button --- apps/desktop/src/App.vue | 2 +- .../src/components/layout/SqlLibraryPanel.vue | 4 ++ .../ui/dialog/DialogDescription.vue | 2 +- .../src/lib/tableStructureEditorState.ts | 52 +++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index e7268a03e6..39e7f9acd8 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -1485,7 +1485,7 @@ onUnmounted(() => {
- +
diff --git a/apps/desktop/src/components/layout/SqlLibraryPanel.vue b/apps/desktop/src/components/layout/SqlLibraryPanel.vue index 826a932c71..e87c850abb 100644 --- a/apps/desktop/src/components/layout/SqlLibraryPanel.vue +++ b/apps/desktop/src/components/layout/SqlLibraryPanel.vue @@ -779,6 +779,7 @@ function showDropInside(targetId: string) { diff --git a/apps/desktop/src/lib/tableStructureEditorState.ts b/apps/desktop/src/lib/tableStructureEditorState.ts index 3477bfd15b..2944ab2f7d 100644 --- a/apps/desktop/src/lib/tableStructureEditorState.ts +++ b/apps/desktop/src/lib/tableStructureEditorState.ts @@ -374,6 +374,53 @@ export const QUESTDB_TYPE_LENGTHS: Record = { export const DEFAULT_TYPE_LENGTH_DISABLES: string[] = []; +export const POSTGRES_TYPE_LENGTH_DISABLES: string[] = [ + "bigint", + "int8", + "bigserial", + "serial8", + "boolean", + "bool", + "box", + "bytea", + "cidr", + "circle", + "date", + "double precision", + "float", + "float8", + "inet", + "integer", + "int", + "int4", + "json", + "jsonb", + "line", + "lseg", + "macaddr", + "macaddr8", + "money", + "path", + "pg_lsn", + "pg_snapshot", + "point", + "polygon", + "real", + "float4", + "smallint", + "int2", + "smallserial", + "serial2", + "serial", + "serial4", + "text", + "tsquery", + "tsvector", + "txid_snapshot", + "uuid", + "xml", +]; + export function parseExtraToColumnExtra(extra: string | null | undefined, databaseType?: DatabaseType): ColumnExtra { const result: ColumnExtra = {}; if (!extra) return result; @@ -610,6 +657,9 @@ export function combineDataType(baseType: string, params: string): string { } export function combineDataTypeForDatabase(dbType: DatabaseType | undefined, baseType: string, params: string): string { + if (isDataTypeLengthDisabled(dbType, baseType)) { + return baseType; + } return combineDataType(baseType, normalizeDataTypeParams(dbType, baseType, params)); } @@ -673,6 +723,8 @@ export function isDataTypeLengthDisabled(_dbType: DatabaseType | undefined, base return key !== "geohash" && key !== "decimal"; } else if (_dbType === "manticoresearch") { return key !== "bit" && key !== "float_vector"; + } else if (_dbType === "postgres" || _dbType === "gaussdb" || _dbType === "kwdb" || _dbType === "opengauss" || _dbType === "highgo" || _dbType === "vastbase" || _dbType === "kingbase") { + return POSTGRES_TYPE_LENGTH_DISABLES.includes(key); } else { return DEFAULT_TYPE_LENGTH_DISABLES.includes(key); }