From 5a0abba1fc69b3237bc1bb2d2399fa3119437a9d Mon Sep 17 00:00:00 2001 From: SwallowGG <1558143046@qq.com> Date: Tue, 17 Oct 2023 22:28:07 +0800 Subject: [PATCH 1/2] Add operation log --- .../ai/chat2db/plugin/mysql/builder/MysqlSqlBuilder.java | 7 ++++--- .../ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/chat2db-server/chat2db-plugins/chat2db-mysql/src/main/java/ai/chat2db/plugin/mysql/builder/MysqlSqlBuilder.java b/chat2db-server/chat2db-plugins/chat2db-mysql/src/main/java/ai/chat2db/plugin/mysql/builder/MysqlSqlBuilder.java index 4d126de9d..aa404f466 100644 --- a/chat2db-server/chat2db-plugins/chat2db-mysql/src/main/java/ai/chat2db/plugin/mysql/builder/MysqlSqlBuilder.java +++ b/chat2db-server/chat2db-plugins/chat2db-mysql/src/main/java/ai/chat2db/plugin/mysql/builder/MysqlSqlBuilder.java @@ -95,9 +95,10 @@ public String buildModifyTaleSql(Table oldTable, Table newTable) { script.append("\t").append(mysqlIndexTypeEnum.buildModifyIndex(tableIndex)).append(",\n"); } } - - script = new StringBuilder(script.substring(0, script.length() - 2)); - script.append(";"); + if(script.length()>2) { + script = new StringBuilder(script.substring(0, script.length() - 2)); + script.append(";"); + } return script.toString(); } diff --git a/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java b/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java index 1a7eb5895..93e691d97 100644 --- a/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java +++ b/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java @@ -92,9 +92,10 @@ public String buildModifyTaleSql(Table oldTable, Table newTable) { script.append("\t").append(mysqlIndexTypeEnum.buildModifyIndex(tableIndex)).append(";\n"); } } - - script = new StringBuilder(script.substring(0, script.length() - 2)); - script.append(";"); + if(script.length()>2) { + script = new StringBuilder(script.substring(0, script.length() - 2)); + script.append(";"); + } return script.toString(); } From 2728259491690a7bd7dcc7c9a0e80d8a8a3e7289 Mon Sep 17 00:00:00 2001 From: SwallowGG <1558143046@qq.com> Date: Tue, 17 Oct 2023 22:54:35 +0800 Subject: [PATCH 2/2] Add operation log --- .../ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java b/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java index 93e691d97..85096d600 100644 --- a/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java +++ b/chat2db-server/chat2db-plugins/chat2db-oracle/src/main/java/ai/chat2db/plugin/oracle/builder/OracleSqlBuilder.java @@ -67,10 +67,10 @@ public String buildModifyTaleSql(Table oldTable, Table newTable) { if (!StringUtils.equalsIgnoreCase(oldTable.getName(), newTable.getName())) { script.append("ALTER TABLE "). append("\"").append(oldTable.getSchemaName()).append("\".\"").append(oldTable.getName()).append("\""); - script.append(" ").append("RENAME TO ").append("\"").append(newTable.getName()).append("\"").append(";"); + script.append(" ").append("RENAME TO ").append("\"").append(newTable.getName()).append("\"").append(";\n"); } if (!StringUtils.equalsIgnoreCase(oldTable.getComment(), newTable.getComment())) { - script.append("\n").append(buildTableComment(newTable)).append(";"); + script.append("").append(buildTableComment(newTable)).append(";\n"); }