Skip to content

Commit

Permalink
fix h2 sql error
Browse files Browse the repository at this point in the history
  • Loading branch information
曾文超 Reid Zeng committed Dec 6, 2023
1 parent 04b1080 commit 95a33cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion note.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
待开发功能:
针对常见的错误, 直接在控制台显示具体的错误, 不需要打印调用栈
子查询模式下, 检查子查询的长度(只有第一个select才需要指定列名称, 后续select不需要指定列名称)
去掉h2数据库的支持?

代码重构:
Sql, 根据不同的语句类型, 拆分成不同的子类.
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/zwc/sqldataprocessor/SqlExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static String renderSql(String sql, Map<String, DataList> tables, String databas
execRawSql(createTempTableSql, databaseName);

// 分批导入数据
List<DataList> dataLists = table.split(10000);
List<DataList> dataLists = table.split(1000);
for (DataList dataList : dataLists) {
String dataInsertSql = "insert into " + tempTableName + " ";
dataInsertSql += renderSelectSql(dataList, databaseName);
Expand Down Expand Up @@ -287,7 +287,7 @@ static String renderSelectSql(List<String> rowValues, DataList table) {
selectColumnFormat = "%s as `%s`";
} else {
value = value.replace("\\", "\\\\");
value = value.replace("'", "\\'");
value = value.replace("'", "''");
selectColumnFormat = "'%s' as `%s`";
}
}
Expand Down Expand Up @@ -354,8 +354,7 @@ static String renderValueClause(List<String> rowValues, DataList table) {
if (value == null) {
values.add(null);
} else {
value = value.replace("\\", "\\\\");
value = value.replace("'", "\\'");
value = value.replace("'", "''");
values.add("'" + value + "'");
}
}
Expand Down

0 comments on commit 95a33cb

Please sign in to comment.