25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(postgres): support array types when adding columns
zipg50c42d89358d
diff --git a/apps/desktop/src/lib/table/tableStructureEditorState.ts b/apps/desktop/src/lib/table/tableStructureEditorState.tsindex 36b348f43c..fb0af64801 100644--- a/apps/desktop/src/lib/table/tableStructureEditorState.ts+++ b/apps/desktop/src/lib/table/tableStructureEditorState.ts@@ -5,6 +5,12 @@ export function hasExistingColumnTypeChange(columns: readonly EditableStructureCreturn columns.some((column) => !!column.original && !column.markedForDrop && column.dataType !== column.original.data_type);}+const POSTGRES_SERIAL_PSEUDO_TYPES = new Set(["smallserial", "serial", "bigserial"]);++function withPostgresArrayTypes(types: readonly string[]): string[] {+ return [...types, ...types.filter((type) => !POSTGRES_SERIAL_PSEUDO_TYPES.has(type)).map((type) => `${type}[]`)];+}+export const DATA_TYPE_OPTIONS: Record<string, string[]> = {mysql: ["tinyint",@@ -58,7 +64,7 @@ export const DATA_TYPE_OPTIONS: Record<string, string[]> = {"multipolygon","geometrycollection",],- postgres: [+ postgres: withPostgresArrayTypes(["smallint","int2","integer",@@ -122,7 +128,7 @@ export const DATA_TYPE_OPTIONS: Record<string, string[]> = {"tstzrange","daterange","oid",- ],+ ]),sqlite: ["integer", "real", "text", "blob", "numeric"],rqlite: ["integer", "real", "text", "blob", "numeric"],turso: ["integer", "real", "text", "blob", "numeric"],@@ -1161,7 +1167,7 @@ export function isDataTypeLengthDisabled(_dbType: DatabaseType | undefined, base} else if (_dbType === "manticoresearch") {return key !== "bit" && key !== "float_vector";} else if (_dbType === "postgres" || _dbType === "gaussdb" || _dbType === "kwdb" || _dbType === "opengauss" || _dbType === "highgo" || _dbType === "uxdb" || _dbType === "vastbase" || _dbType === "kingbase") {- return POSTGRES_TYPE_LENGTH_DISABLES.includes(key);+ return key.endsWith("[]") || POSTGRES_TYPE_LENGTH_DISABLES.includes(key);} else if (isOracleLikeStructureType(_dbType)) {// Dameng/Oracle integer aliases have fixed precision; MySQL-style display widths generate invalid DDL.return ORACLE_LIKE_TYPE_LENGTH_DISABLES.includes(key);diff --git a/packages/app-tests/tableStructureEditorState.test.ts b/packages/app-tests/tableStructureEditorState.test.tsindex 8e7983d653..5c755569a9 100644--- a/packages/app-tests/tableStructureEditorState.test.ts+++ b/packages/app-tests/tableStructureEditorState.test.ts@@ -14,6 +14,7 @@ import {generateUniqueIndexName,getColumnEditorControls,getDataTypeOptions,+ isDataTypeLengthDisabled,isProtectedManticoreIdColumn,isDamengIdentityCompatibleDataType,isMysqlEnumDataType,@@ -485,6 +486,21 @@ test("returns data type options for compatible table structure editors", () => {assert.equal(getDataTypeOptions("sqlserver").includes("nvarchar"), true);});+test("returns PostgreSQL array type options without serial pseudo-types", () => {+ const options = getDataTypeOptions("postgres");+ assert.equal(options.includes("integer[]"), true);+ assert.equal(options.includes("character varying[]"), true);+ assert.equal(options.includes("jsonb[]"), true);+ assert.equal(options.includes("serial[]"), false);+ assert.equal(options.includes("smallserial[]"), false);+ assert.equal(options.includes("bigserial[]"), false);+});++test("does not append length parameters after PostgreSQL array brackets", () => {+ assert.equal(isDataTypeLengthDisabled("postgres", "varchar[]"), true);+ assert.equal(combineDataTypeForDatabase("postgres", "varchar[]", "20"), "varchar[]");+});+test("returns Xugu data type options", () => {const options = getDataTypeOptions("xugu");assert.equal(options.includes("INTEGER"), true);