浏览代码

db: create new session for MySQL after changing attribute (#6338)

ᴜɴᴋɴᴡᴏɴ 4 年之前
父节点
当前提交
c56db8f2c4
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      internal/db/db.go

+ 4 - 1
internal/db/db.go

@@ -187,7 +187,10 @@ func Init() (*gorm.DB, error) {
 		conf.UsePostgreSQL = true
 	case "mysql":
 		conf.UseMySQL = true
-		db = db.Set("gorm:table_options", "ENGINE=InnoDB")
+		db = db.Set("gorm:table_options", "ENGINE=InnoDB").
+			Session(&gorm.Session{
+				WithConditions: true,
+			})
 	case "sqlite3":
 		conf.UseSQLite3 = true
 	case "mssql":