From b24409f314d9a845f0050d3e174dea4d82fbb6a4 Mon Sep 17 00:00:00 2001 From: wewelove88 Date: Mon, 19 Feb 2024 15:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGbase8a=E5=BB=BA=E8=A1=A8?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gitee/dbswitch/common/type/ProductTypeEnum.java | 11 ++++++++++- .../com/gitee/dbswitch/util/GenerateSqlUtils.java | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dbswitch-common/src/main/java/com/gitee/dbswitch/common/type/ProductTypeEnum.java b/dbswitch-common/src/main/java/com/gitee/dbswitch/common/type/ProductTypeEnum.java index becd9a4b..e448a026 100644 --- a/dbswitch-common/src/main/java/com/gitee/dbswitch/common/type/ProductTypeEnum.java +++ b/dbswitch-common/src/main/java/com/gitee/dbswitch/common/type/ProductTypeEnum.java @@ -235,7 +235,16 @@ public enum ProductTypeEnum { * @return boolean */ public boolean isLikeMysql() { - return this == MYSQL || this == MARIADB || this == GBASE8A; + return this == MYSQL || this == MARIADB; + } + + /** + * 类似于MySQL系列的数据库类型 + * + * @return boolean + */ + public boolean isLikeGbase8a() { + return this == GBASE8A; } /** diff --git a/dbswitch-core/src/main/java/com/gitee/dbswitch/util/GenerateSqlUtils.java b/dbswitch-core/src/main/java/com/gitee/dbswitch/util/GenerateSqlUtils.java index a5ebc2c0..f464d2ee 100644 --- a/dbswitch-core/src/main/java/com/gitee/dbswitch/util/GenerateSqlUtils.java +++ b/dbswitch-core/src/main/java/com/gitee/dbswitch/util/GenerateSqlUtils.java @@ -99,7 +99,12 @@ public final class GenerateSqlUtils { } sb.append(")"); - if (type.isLikeMysql()) { + if (type.isLikeGbase8a()) { + sb.append("ENGINE=EXPRESS DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"); + if (withRemarks && StringUtils.isNotBlank(tableRemarks)) { + sb.append(String.format(" COMMENT='%s' ", tableRemarks.replace("'", "\\'"))); + } + } else if (type.isLikeMysql()) { sb.append("ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"); if (withRemarks && StringUtils.isNotBlank(tableRemarks)) { sb.append(String.format(" COMMENT='%s' ", tableRemarks.replace("'", "\\'")));