mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 02:32:33 +08:00
Support table schema edit
This commit is contained in:
@ -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("."));
|
||||
|
@ -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());
|
||||
}}
|
||||
|
Reference in New Issue
Block a user