!55 修复基于建表SQL生成代码 列名没有COMMENT注释报错的问题

Merge pull request !55 from 夜丶点缀了一个人的落寞/hotfix-tool-codegen
pull/2/head
芋道源码 2021-11-08 08:33:49 +00:00 committed by Gitee
commit c84e19e14e
1 changed files with 3 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import org.apache.commons.collections4.keyvalue.DefaultKeyValue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import static com.alibaba.druid.sql.SQLUtils.normalize; import static com.alibaba.druid.sql.SQLUtils.normalize;
@ -97,7 +98,8 @@ public class ToolCodegenSQLParser {
columns.add(ToolSchemaColumnDO.builder() columns.add(ToolSchemaColumnDO.builder()
.columnName(normalize(definition.getColumnName())) .columnName(normalize(definition.getColumnName()))
.columnType(definition.getDataType().toString()) .columnType(definition.getDataType().toString())
.columnComment(normalize(definition.getComment().toString())) .columnComment(Objects.isNull(definition.getComment()) ? ""
: normalize(definition.getComment().toString()))
.nullable(!text.contains(" NOT NULL")) .nullable(!text.contains(" NOT NULL"))
.primaryKey(false) .primaryKey(false)
.autoIncrement(text.contains("AUTO_INCREMENT")) .autoIncrement(text.contains("AUTO_INCREMENT"))