Support table schema edit

This commit is contained in:
SwallowGG
2023-10-09 18:27:24 +08:00
parent 51452dbfd0
commit ab1cad3cbe
16 changed files with 626 additions and 7 deletions

View File

@ -6,12 +6,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import ai.chat2db.plugin.sqlserver.type.SqlServerColumnTypeEnum;
import ai.chat2db.plugin.sqlserver.type.SqlServerIndexTypeEnum;
import ai.chat2db.spi.MetaData;
import ai.chat2db.spi.jdbc.DefaultMetaService;
import ai.chat2db.spi.model.Function;
import ai.chat2db.spi.model.Procedure;
import ai.chat2db.spi.model.Table;
import ai.chat2db.spi.model.Trigger;
import ai.chat2db.spi.model.*;
import ai.chat2db.spi.sql.SQLExecutor;
import jakarta.validation.constraints.NotEmpty;
import org.apache.commons.lang3.StringUtils;
@ -226,6 +225,17 @@ public class SqlServerMetaData extends DefaultMetaService implements MetaData {
});
}
@Override
public TableMeta getTableMeta(String databaseName, String schemaName, String tableName) {
return TableMeta.builder()
.columnTypes(SqlServerColumnTypeEnum.getTypes())
.charsets(null)
.collations(null)
.indexTypes(SqlServerIndexTypeEnum.getIndexTypes())
.build();
}
@Override
public String getMetaDataName(String... names) {
return Arrays.stream(names).filter(name -> StringUtils.isBlank(name)).map(name -> "[" + name + "]").collect(Collectors.joining("."));

View File

@ -1,10 +1,14 @@
package ai.chat2db.plugin.sqlserver.type;
import ai.chat2db.spi.enums.EditStatus;
import ai.chat2db.spi.model.IndexType;
import ai.chat2db.spi.model.TableIndex;
import ai.chat2db.spi.model.TableIndexColumn;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
public enum SqlServerIndexTypeEnum {
PRIMARY_KEY("Primary", "PRIMARY KEY"),
@ -27,6 +31,16 @@ public enum SqlServerIndexTypeEnum {
XML("XML", "XML INDEX");
public IndexType getIndexType() {
return indexType;
}
public void setIndexType(IndexType indexType) {
this.indexType = indexType;
}
private IndexType indexType;
public String getName() {
return name;
@ -44,6 +58,7 @@ public enum SqlServerIndexTypeEnum {
SqlServerIndexTypeEnum(String name, String keyword) {
this.name = name;
this.keyword = keyword;
this.indexType = new IndexType(name);
}
@ -116,4 +131,7 @@ public enum SqlServerIndexTypeEnum {
return script.toString();
}
}
public static List<IndexType> getIndexTypes() {
return Arrays.asList(SqlServerIndexTypeEnum.values()).stream().map(SqlServerIndexTypeEnum::getIndexType).collect(java.util.stream.Collectors.toList());
}}