对原有列 增加 顺序 order

This commit is contained in:
Kevin 2024-07-05 19:05:46 +08:00
parent 6b60aef692
commit de8fd248fe
2 changed files with 25 additions and 3 deletions

View File

@ -75,7 +75,19 @@ public class Column implements Serializable, Cloneable {
* 是否为主键 * 是否为主键
*/ */
private boolean isPk; private boolean isPk;
// ----------------------------------------------------- Fields end /**
* 列字段顺序
*/
private int order;
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
// ----------------------------------------------------- Fields end
/** /**
* 创建列对象 * 创建列对象
@ -137,7 +149,7 @@ public class Column implements Serializable, Cloneable {
this.isNullable = columnMetaRs.getBoolean("NULLABLE"); this.isNullable = columnMetaRs.getBoolean("NULLABLE");
this.remarks = columnMetaRs.getString("REMARKS"); this.remarks = columnMetaRs.getString("REMARKS");
this.columnDef = columnMetaRs.getString("COLUMN_DEF"); this.columnDef = columnMetaRs.getString("COLUMN_DEF");
this.order = columnMetaRs.getRow();
// 保留小数位数 // 保留小数位数
try { try {
this.digit = columnMetaRs.getInt("DECIMAL_DIGITS"); this.digit = columnMetaRs.getInt("DECIMAL_DIGITS");
@ -395,7 +407,7 @@ public class Column implements Serializable, Cloneable {
@Override @Override
public String toString() { public String toString() {
return "Column [tableName=" + tableName + ", name=" + name + ", type=" + type + ", size=" + size + ", isNullable=" + isNullable + "]"; return "Column [tableName=" + tableName + ", name=" + name + ", type=" + type + ", size=" + size + ", isNullable=" + isNullable + ", order=" + order + "]";
} }
@Override @Override

View File

@ -54,4 +54,14 @@ public class MetaUtilTest {
final Table table = MetaUtil.getTableMeta(ds, "user_1"); final Table table = MetaUtil.getTableMeta(ds, "user_1");
Assertions.assertEquals(table.getIndexInfoList().size(), 2); Assertions.assertEquals(table.getIndexInfoList().size(), 2);
} }
/**
* 增加 列顺序字段
*/
@Test
public void getTableColumnTest() {
final Table table = MetaUtil.getTableMeta(ds, "user");
System.out.println(table.getColumns());
Assertions.assertEquals(SetUtil.of("id"), table.getPkNames());
}
} }