Skip to content

Commit

Permalink
fix: 修复在Migrate中,且db.DryRun=true时,GetColumnComment方法因获取不到当前库名而报错
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnanyang authored and iTanken committed Feb 10, 2025
1 parent 4b69dd2 commit 66da4f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ func (m Migrator) GetColumnComment(stmt *gorm.Statement, fieldDBName string) (de
if m.DB.DryRun {
queryTx.DryRun = false
}
var currentDatabase string
_ = queryTx.Raw("SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA');").Row().Scan(&currentDatabase)
var comment sql.NullString
queryTx.Raw("SELECT COMMENTS FROM ALL_COL_COMMENTS WHERE SCHEMA_NAME = ? AND TABLE_NAME = ? AND COLUMN_NAME = ?",
m.CurrentDatabase(), stmt.Table, fieldDBName).Scan(&comment)
currentDatabase, stmt.Table, fieldDBName).Scan(&comment)
if comment.Valid {
description = comment.String
}
Expand Down

0 comments on commit 66da4f8

Please sign in to comment.