Skip to content

Commit db58264

Browse files
committed
feat(database): improve getTableColumns method #80
- Refactored the getTableColumns method in GenSqlScriptBySelection.kt to use mapNotNull instead of flatMap for better performance. - Added logging to display the table name and its corresponding columns for better debugging and understanding.
1 parent 20735ee commit db58264

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

exts/database/src/main/kotlin/cc/unitmesh/database/actions/GenSqlScriptBySelection.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,15 @@ data class DbContextActionProvider(val dasTables: List<DasTable>) {
197197
* @return A list of column names from the specified tables.
198198
*/
199199
fun getTableColumns(tables: List<String>): List<String> {
200-
return dasTables.flatMap { tableName ->
200+
return dasTables.mapNotNull { tableName ->
201201
if (tables.contains(tableName.name)) {
202-
DasUtil.getColumns(tableName).map {
202+
val columns = DasUtil.getColumns(tableName).map {
203203
"${it.name}: ${it.dasType.toDataType()}"
204204
}
205+
206+
"TableName: ${tableName.name}, Columns: $columns"
205207
} else {
206-
emptyList()
208+
null
207209
}
208210
}
209211
}

0 commit comments

Comments
 (0)