Skip to content

Commit

Permalink
refactor: 优化表结构解析
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Jun 27, 2024
1 parent 36bdddc commit f773c2d
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected Optional<RDBTableMetadata> doParse(String name) {
.stream()
.map(record -> {
RDBColumnMetadata column = metaData.newColumn();
record.getString("table_name").ifPresent(metaData::setRealName);
applyColumnInfo(column, record);
return column;
})
Expand Down Expand Up @@ -114,8 +115,9 @@ public Mono<RDBTableMetadata> parseByNameReactive(String name) {
ReactiveSqlExecutor reactiveSqlExecutor = getReactiveSqlExecutor();
//列
Mono<List<RDBColumnMetadata>> columns = reactiveSqlExecutor
.select(template(getTableMetaSql(null), param), new RecordResultWrapper())
.select(template(getTableMetaSql(name), param), new RecordResultWrapper())
.map(record -> {
record.getString("table_name").ifPresent(metaData::setRealName);
RDBColumnMetadata column = metaData.newColumn();
applyColumnInfo(column, record);
metaData.addColumn(column);
Expand All @@ -129,10 +131,11 @@ public Mono<RDBTableMetadata> parseByNameReactive(String name) {
.singleOrEmpty();

//加载索引
Flux<RDBIndexMetadata> index = schema.findFeature(IndexMetadataParser.ID)
.map(parser -> parser.parseTableIndexReactive(name))
.orElseGet(Flux::empty)
.doOnNext(metaData::addIndex);
Flux<RDBIndexMetadata> index = schema
.findFeature(IndexMetadataParser.ID)
.map(parser -> parser.parseTableIndexReactive(name))
.orElseGet(Flux::empty)
.doOnNext(metaData::addIndex);

return Flux
.merge(columns, comments, index)
Expand Down

0 comments on commit f773c2d

Please sign in to comment.