(txn *sql.Tx, schemaName string)
| 357 | } |
| 358 | |
| 359 | func getTableComments(txn *sql.Tx, schemaName string) (map[db.TableKey]string, error) { |
| 360 | tableCommentMap := make(map[db.TableKey]string) |
| 361 | |
| 362 | query := "" |
| 363 | if schemaName == "" { |
| 364 | query = fmt.Sprintf(` |
| 365 | SELECT OWNER, TABLE_NAME, COMMENTS |
| 366 | FROM all_tab_comments |
| 367 | WHERE OWNER NOT IN (%s) AND OWNER NOT LIKE 'APEX_%%' AND COMMENTS IS NOT NULL |
| 368 | ORDER BY OWNER, TABLE_NAME`, systemSchema) |
| 369 | } else { |
| 370 | query = fmt.Sprintf(` |
| 371 | SELECT OWNER, TABLE_NAME, COMMENTS |
| 372 | FROM all_tab_comments |
| 373 | WHERE OWNER = '%s' AND COMMENTS IS NOT NULL |
| 374 | ORDER BY TABLE_NAME`, schemaName) |
| 375 | } |
| 376 | slog.Debug("running get table comments query") |
| 377 | rows, err := txn.Query(query) |
| 378 | if err != nil { |
| 379 | return nil, util.FormatErrorWithQuery(err, query) |
| 380 | } |
| 381 | defer rows.Close() |
| 382 | |
| 383 | for rows.Next() { |
| 384 | var schemaName, tableName, comment string |
| 385 | if err := rows.Scan(&schemaName, &tableName, &comment); err != nil { |
| 386 | return nil, err |
| 387 | } |
| 388 | key := db.TableKey{Schema: schemaName, Table: tableName} |
| 389 | tableCommentMap[key] = common.SanitizeUTF8String(comment) |
| 390 | } |
| 391 | if err := rows.Err(); err != nil { |
| 392 | return nil, util.FormatErrorWithQuery(err, query) |
| 393 | } |
| 394 | if err := rows.Close(); err != nil { |
| 395 | return nil, errors.Wrapf(err, "failed to close rows") |
| 396 | } |
| 397 | |
| 398 | return tableCommentMap, nil |
| 399 | } |
| 400 | |
| 401 | func getTableColumnComments(txn *sql.Tx, schemaName string) (map[db.ColumnKey]string, error) { |
| 402 | columnCommentsMap := make(map[db.ColumnKey]string) |
no test coverage detected