From d67d1e685a76129ec5d71da460042472b7fa2479 Mon Sep 17 00:00:00 2001 From: demoManito <1430482733@qq.com> Date: Tue, 21 May 2024 17:22:17 +0800 Subject: [PATCH] define default driver name constant --- mysql.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql.go b/mysql.go index bdef77b..8b6ef3d 100644 --- a/mysql.go +++ b/mysql.go @@ -22,6 +22,8 @@ import ( ) const ( + DefaultDriverName = "mysql" + AutoRandomTag = "auto_random()" // Treated as an auto_random field for tidb ) @@ -80,7 +82,7 @@ func New(config Config) gorm.Dialector { } func (dialector Dialector) Name() string { - return "mysql" + return DefaultDriverName } // NowFunc return now func @@ -107,7 +109,7 @@ func (dialector Dialector) Apply(config *gorm.Config) error { func (dialector Dialector) Initialize(db *gorm.DB) (err error) { if dialector.DriverName == "" { - dialector.DriverName = "mysql" + dialector.DriverName = DefaultDriverName } if dialector.DefaultDatetimePrecision == nil {