From aeecffb51798c66e09d13288a5c5f7b5eea5a32b Mon Sep 17 00:00:00 2001 From: Syngnat Date: Sat, 18 Jul 2026 16:15:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(table-designer):=20=E8=A1=A5?= =?UTF-8?q?=E9=BD=90=20MySQL=20=E7=A9=BA=E9=97=B4=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 补充 Geometry、Point、MultiPoint 等八种 MySQL 空间类型候选 - 保留自定义字段类型表达式在建表和改表 SQL 中的原样输出 - 增加空间类型候选及 POINT SRID 属性回归测试 Fixes #341 --- .../components/tableDesignerSchemaSql.test.ts | 22 +++++++++++++++++++ frontend/src/utils/sqlDialect.test.ts | 13 +++++++++++ frontend/src/utils/sqlDialect.ts | 8 +++++++ 3 files changed, 43 insertions(+) diff --git a/frontend/src/components/tableDesignerSchemaSql.test.ts b/frontend/src/components/tableDesignerSchemaSql.test.ts index 38a8a863..60a799a5 100644 --- a/frontend/src/components/tableDesignerSchemaSql.test.ts +++ b/frontend/src/components/tableDesignerSchemaSql.test.ts @@ -358,6 +358,28 @@ describe('tableDesignerSchemaSql', () => { expect(tdengineSql).not.toContain('AFTER'); }); + it('keeps freely entered MySQL spatial type attributes in schema SQL', () => { + const location = baseColumn({ + _key: 'location', + name: 'location', + type: 'POINT SRID 4326', + nullable: 'NO', + }); + const createSql = buildCreateTablePreviewSql({ + tableName: 'places', + dbType: 'mysql', + columns: [location], + }); + const alterSql = buildAlterTablePreviewSql(buildInput({ + tableName: 'places', + originalColumns: [], + columns: [location], + })); + + expect(createSql).toContain('`location` POINT SRID 4326 NOT NULL'); + expect(alterSql).toContain('ADD COLUMN `location` POINT SRID 4326 NOT NULL'); + }); + it('builds StarRocks create table preview with OLAP engine and conservative distribution', () => { const sql = buildCreateTablePreviewSql({ tableName: 'sales.orders', diff --git a/frontend/src/utils/sqlDialect.test.ts b/frontend/src/utils/sqlDialect.test.ts index 8b900f20..c68172f0 100644 --- a/frontend/src/utils/sqlDialect.test.ts +++ b/frontend/src/utils/sqlDialect.test.ts @@ -79,6 +79,19 @@ describe('sqlDialect', () => { expect(values(resolveColumnTypeOptions('duckdb'))).toContain('STRUCT'); }); + it('offers every MySQL spatial column type', () => { + expect(values(resolveColumnTypeOptions('mysql'))).toEqual(expect.arrayContaining([ + 'geometry', + 'point', + 'linestring', + 'polygon', + 'multipoint', + 'multilinestring', + 'multipolygon', + 'geometrycollection', + ])); + }); + it('resolves Apache IoTDB completion keywords and functions independently', () => { expect(resolveSqlKeywords('iotdb')).toEqual(expect.arrayContaining(['ALIGN BY DEVICE', 'SHOW TIMESERIES', 'WITH DATATYPE'])); expect(names(resolveSqlFunctions('iotdb'))).toEqual(expect.arrayContaining(['DATE_BIN', 'DIFF', 'TOP_K'])); diff --git a/frontend/src/utils/sqlDialect.ts b/frontend/src/utils/sqlDialect.ts index 0c8e81bc..6c80f45d 100644 --- a/frontend/src/utils/sqlDialect.ts +++ b/frontend/src/utils/sqlDialect.ts @@ -303,6 +303,14 @@ const MYSQL_TYPES = optionValues([ 'timestamp', 'year', 'json', + 'geometry', + 'point', + 'linestring', + 'polygon', + 'multipoint', + 'multilinestring', + 'multipolygon', + 'geometrycollection', 'enum', 'set', 'bit(1)',