!1235 hutool Column 暂未有 字段顺序,故新增列顺序字段 order

Merge pull request !1235 from 无极侠岚/v6-dev
This commit is contained in:
Looly 2024-07-06 02:44:59 +00:00 committed by Gitee
commit 6873b39095
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 25 additions and 3 deletions

View File

@ -75,7 +75,19 @@ public class Column implements Serializable, Cloneable {
* 是否为主键
*/
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.remarks = columnMetaRs.getString("REMARKS");
this.columnDef = columnMetaRs.getString("COLUMN_DEF");
this.order = columnMetaRs.getRow();
// 保留小数位数
try {
this.digit = columnMetaRs.getInt("DECIMAL_DIGITS");
@ -395,7 +407,7 @@ public class Column implements Serializable, Cloneable {
@Override
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

View File

@ -54,4 +54,14 @@ public class MetaUtilTest {
final Table table = MetaUtil.getTableMeta(ds, "user_1");
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());
}
}