diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java index bb664a1d5..d9f253881 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java @@ -64,10 +64,17 @@ public class ToolCodegenSQLParser { private static ToolSchemaTableDO parseTable(SQLCreateTableStatement statement) { return ToolSchemaTableDO.builder() .tableName(statement.getTableSource().getTableName(true)) - .tableComment(((SQLCharExpr) statement.getComment()).getText()) + .tableComment(getCommentText(statement)) .build(); } + private static String getCommentText(SQLCreateTableStatement statement) { + if (statement == null || statement.getComment() == null) { + return ""; + } + return ((SQLCharExpr) statement.getComment()).getText(); + } + private static List parseColumns(SQLCreateTableStatement statement) { List columns = new ArrayList<>(); statement.getTableElementList().forEach(element -> parseColumn(columns, element));