Last active
August 2, 2022 10:57
-
-
Save mingyang91/578747e27d0d68553f66ff60405a8827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class V2EX_stream { | |
public List<String> getForeignKeyTable(List<String> tableNames, | |
DataSourceEntity info, | |
List<ForeignKeyInfo> foreignKeyInfos) { | |
var childTables = tableNames.stream() | |
.map(tableName -> findAllTable(info.getDataBaseName(), tableName)) | |
.filter(column -> !DB_KEYWORD_SET.contains(column.getColumnName().toUpperCase())) | |
.flatMap(columnInfo -> foreignKeyInfos.stream() | |
.filter(it -> it.getSourceTableName().equals(columnInfo.getTableName()) && | |
it.getSourceColumnName().equals(columnInfo.getColumnName()) | |
) | |
) | |
.map(ForeignKeyInfo::getTargetTableName) | |
.toList(); | |
if (childTables.isEmpty()) { | |
return Collections.emptyList(); | |
} else { | |
return getForeignKeyTable(childTables, info, foreignKeyInfos); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment