修复字段不存在的问题

This commit is contained in:
SwallowGG
2024-06-25 21:29:14 +08:00
parent 737c1fb284
commit 8691c1955f
10 changed files with 160 additions and 4 deletions

View File

@ -25,6 +25,9 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
continue;
}
PostgreSQLColumnTypeEnum typeEnum = PostgreSQLColumnTypeEnum.getByType(column.getColumnType());
if(typeEnum == null){
continue;
}
script.append("\t").append(typeEnum.buildCreateColumnSql(column)).append(",\n");
}
Map<Boolean, List<TableIndex>> tableIndexMap = table.getIndexList().stream()
@ -37,6 +40,9 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
continue;
}
PostgreSQLIndexTypeEnum indexTypeEnum = PostgreSQLIndexTypeEnum.getByType(index.getType());
if(indexTypeEnum == null){
continue;
}
script.append("\t").append("").append(indexTypeEnum.buildIndexScript(index));
script.append(",\n");
}
@ -53,6 +59,9 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
}
script.append("\n");
PostgreSQLIndexTypeEnum indexTypeEnum = PostgreSQLIndexTypeEnum.getByType(tableIndex.getType());
if(indexTypeEnum == null){
continue;
}
script.append("").append(indexTypeEnum.buildIndexScript(tableIndex)).append(";");
}
@ -65,12 +74,18 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
List<TableColumn> tableColumnList = table.getColumnList().stream().filter(v -> StringUtils.isNotBlank(v.getComment())).toList();
for (TableColumn tableColumn : tableColumnList) {
PostgreSQLColumnTypeEnum typeEnum = PostgreSQLColumnTypeEnum.getByType(tableColumn.getColumnType());
if(typeEnum == null){
continue;
}
script.append(typeEnum.buildComment(tableColumn, typeEnum)).append("\n");
;
}
List<TableIndex> indexList = table.getIndexList().stream().filter(v -> StringUtils.isNotBlank(v.getComment())).toList();
for (TableIndex index : indexList) {
PostgreSQLIndexTypeEnum indexEnum = PostgreSQLIndexTypeEnum.getByType(index.getType());
if(indexEnum == null){
continue;
}
script.append(indexEnum.buildIndexComment(index)).append("\n");
;
}
@ -105,6 +120,9 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
// append modify column
for (TableColumn tableColumn : newTable.getColumnList()) {
PostgreSQLColumnTypeEnum typeEnum = PostgreSQLColumnTypeEnum.getByType(tableColumn.getColumnType());
if(typeEnum == null){
continue;
}
scriptModify.append("\t").append(typeEnum.buildModifyColumn(tableColumn)).append(",\n");
modify = true;
@ -114,6 +132,9 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
for (TableIndex tableIndex : tableIndexMap.get(Boolean.FALSE)) {
if (StringUtils.isNotBlank(tableIndex.getType())) {
PostgreSQLIndexTypeEnum indexTypeEnum = PostgreSQLIndexTypeEnum.getByType(tableIndex.getType());
if(indexTypeEnum == null){
continue;
}
scriptModify.append("\t").append(indexTypeEnum.buildModifyIndex(tableIndex)).append(",\n");
modify = true;
}
@ -129,6 +150,9 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
for (TableIndex tableIndex : tableIndexMap.get(Boolean.TRUE)) {
if (StringUtils.isNotBlank(tableIndex.getEditStatus()) && StringUtils.isNotBlank(tableIndex.getType())) {
PostgreSQLIndexTypeEnum indexTypeEnum = PostgreSQLIndexTypeEnum.getByType(tableIndex.getType());
if(indexTypeEnum == null){
continue;
}
script.append(indexTypeEnum.buildModifyIndex(tableIndex)).append(";\n");
}
}
@ -141,12 +165,18 @@ public class PostgreSQLSqlBuilder extends DefaultSqlBuilder {
}
for (TableColumn tableColumn : newTable.getColumnList()) {
PostgreSQLColumnTypeEnum typeEnum = PostgreSQLColumnTypeEnum.getByType(tableColumn.getColumnType());
if(typeEnum ==null){
continue;
}
script.append(typeEnum.buildComment(tableColumn, typeEnum)).append("\n");
;
}
List<TableIndex> indexList = newTable.getIndexList().stream().filter(v -> StringUtils.isNotBlank(v.getComment())).toList();
for (TableIndex index : indexList) {
PostgreSQLIndexTypeEnum indexEnum = PostgreSQLIndexTypeEnum.getByType(index.getType());
if(indexEnum == null){
continue;
}
script.append(indexEnum.buildIndexComment(index)).append("\n");
}