From 59758ccb75f03379f1fb557605ddad5dde307af1 Mon Sep 17 00:00:00 2001 From: iTanken <23544702+iTanken@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:57:42 +0800 Subject: [PATCH] perf: modify log level for query field comment to avoid printing excessive useless logs --- migrator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrator.go b/migrator.go index 0162816..1931bec 100644 --- a/migrator.go +++ b/migrator.go @@ -8,6 +8,7 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" + "gorm.io/gorm/logger" "gorm.io/gorm/migrator" "gorm.io/gorm/schema" ) @@ -273,9 +274,8 @@ func (m Migrator) RenameColumn(value interface{}, oldName, newName string) error } func (m Migrator) GetColumnComment(stmt *gorm.Statement, fieldDBName string) (description string) { - queryTx := m.DB + queryTx := m.DB.Session(&gorm.Session{Logger: m.DB.Logger.LogMode(logger.Warn)}) if m.DB.DryRun { - queryTx = m.DB.Session(&gorm.Session{}) queryTx.DryRun = false } var comment sql.NullString